The biggest mistake is (const BYTE*)0x00 : you drop 0x00 to BYTE * , which means that basically you are passing a NULL pointer. Instead, you should create a DWORD variable, put the value that you want to keep in the registry, and pass a pointer to it instead of 0x00 .
In addition, you must change REG_SZ to REG_DWORD if you want to keep the DWORD , otherwise the DWORD will be interpreted as a (somewhat weird) string.
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\pager", 0, KEY_ALL_ACCESS, &hKey); DWORD value=0; RegSetValueEx(hKey, TEXT("Save"), 0, REG_DWORD, (const BYTE*)&value, sizeof(value)); RegCloseKey(hKey);
But most importantly, you should really check the return values of these functions: now you just “hope” that they work, ignoring any failure and continuing the flow of commands, which can lead to unforeseen situations.
If you checked the error codes, you would immediately notice that the RegSetValueEx function does not work, and the error code may be something like an “invalid parameter” that would point you in the right direction.
source share