Robię to w ten sposób
HKEY hKey;
LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
bool bExistsAndSuccess (lRes == ERROR_SUCCESS);
bool bDoesNotExistsSpecifically (lRes == ERROR_FILE_NOT_FOUND);
DWORD strValueOfBinDir;
std::wstring strKeyDefaultValue;
GetDWORDRegKey(hKey, L"InstallDate", strValueOfBinDir, NULL);
ostringstream stream;
stream << strValueOfBinDir;
string str = stream.str();
MessageBox(NULL, UTF8_To_UTF16(str).c_str(), (LPCWSTR)L"Wartość", MB_ICONINFORMATION | MB_OK);
Zwracana wartość to 0 tak jakby ten klucz nie istniał ale przecież jest tam.
Tutaj już zwraca prawidłową wartość:
GetDWORDRegKey(hKey, L"UBR", strValueOfBinDir, NULL);