>I am setting some keys in an app and I have run into a bit of a bottleneck. I have a key with TWO values. The first is a string and the second is a binary value. I need to be able to set the binary value portion of the key and to date it has been a real party killer.
>
>[Reg KEY]
>HKEY_USERS\Software\Microsoft\Windows\CurrentVersion\Internet Settings
>
>[Key Values]
>EnableAutodisconnect 0000 01 00 00 00
>
>[Key Values I need to have]
>EnableAutodisconnect 0000 00 00 00 00
>
What is the type of the registry value (REG_DWORD, REG_BIN, etc.)? The RegSetValueEx API call (The call needed to write a registry value, as opposed to creating a key) takes a type designator as the third argument. the C prototype for the RegSetValueEx call is:
LONG RegSetValueEx{
hKey hKey,
LPCSTR lpSubKey,
DWORD Reserved,
DWORD dwType,
CONST BYTE *lpData,
DWORD cbDATA
}
Open the registry key whose value you wish to set with RegOpenKey or RegCreateKey, then call RegSetValueEx using the HKEY returned by the open as the first argument, the string name of the key value as the second argument (in your case, EnableAutoDisconnect), a zero as the third argument, the correct type as a number as the fourth argument (probably REG_DWORD or REG_BIN; these are constants you can find in the MSDN docs or the C header file WINREG.H), a void pointer or byte pointer to the buffer containing the data you want written in the fifth argument (in your case, a buffer containing all zeros for a REG_BIN, or an integer 0 for a REG_DWORD), and the length of the data to write as the sixth argument.