Click to See Complete Forum and Search --> : How to write dword and integers to the registry


Rich Scales
September 5th, 1999, 02:52 PM
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

Arno Mantwill
September 8th, 1999, 07:05 PM
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

Ken Sutherland
September 9th, 1999, 12:08 AM
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.

ken@j-mac.co.jp