I'm getting a few "use of old-style cast" warnings which I would like to get rid of, but I don't know enough about this.
Edit:
HKEY_CURRENT_USER
is indeed defined in the WinAPI so I will leave that one alone.
(LPBYTE)&result
: LPBYTE(&result)
and reinterpret_cast<LPBYTE>(&result)
work, but I have no idea if either is equivalent.
So which of these three do I use?
(const BYTE*)&value
: reinterpret_cast<const BYTE*>(&value)
works, but same thing again.
So which of these two do I use?
Some more context:
HKEY hKey;
std::string sResult = "";
if(regOpenKey(KEY_READ, &hKey))
{
DWORD size=1024, type = REG_SZ;
wchar_t result[MAX_PATH];
if(RegQueryValueEx(hKey, key, nullptr, &type, (LPBYTE)&result, &size) == ERROR_SUCCESS)
sResult = str_narrow(result);
}
RegCloseKey(hKey);
and:
HKEY hKey;
if(regOpenKey(KEY_ALL_ACCESS, &hKey))
{
DWORD value = 1;
RegSetValueEx(hKey, key, 0, REG_DWORD, (const BYTE*)&value, sizeof(value));
}
RegCloseKey(hKey);
Thanks for any help :)
HKEY_CURRENT_USER
is defined in the WinAPI, so leave it alone. It could change without warning (although unlikely, but possible).
(LPBYTE)&result: LPBYTE(&result)
works, but again, I have no idea if it's equivalent.
Yes, its the same.
(const BYTE*)&value: reinterpret_cast<const BYTE*>(&value)
works, but same thing again.
The same again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With