How to write dword and integers to the registry
In my application, it needs to be able to write integers to the registry. I've been using the RegSetValueEx function but it says that it can't
convert the number to a char, and I've specified REG_DWORD as the type. Any ideas? Any help would be appreciated. Thanks.
Rich
Re: How to write dword and integers to the registry
Why you don't use the method WriteProfileInt? It's made to write integer values to the registry. Use WriteProfileString to write characters to the registry. (Look at the online help)
I hope that helps
Arno Mantwill
Re: How to write dword and integers to the registry
Just type-cast your integer number to a char, something like this:
nErr = RegQueryValueEx(
hKey, //handle of key to query
lpszEntry, //address of name of value to query
0, //reserved
&nType, //address of buffer for value type
(BYTE *)&nValue, //address of data buffer
&nLen); //address of data buffer size
Note that GetProfileInt (etc.) is fine as long as you are reading from HKEY_CURRENT_USER. If you want to read from HKEY_LOCAL_MACHINE, you have to use RegQueryValueEx.
[email protected]