Click to See Complete Forum and Search --> : please help registry


inbugable
February 15th, 2008, 02:41 PM
i made this code, but did not work. I want to put some data to registry, more exactly a path. Tho code make a key, but did not set the value. Please help

HKEY hkey;
DWORD dwDisposition;
unsigned char boum[7] = "chaine";
int dwSize = sizeof (DWORD);


RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\My Company\\My Application"), 0, NULL, 0, 0, NULL, &hkey, &dwDisposition);
RegSetValueExA(hkey, "La Chaine", NULL, REG_SZ, (LPBYTE)&boum, dwSize);

MrViggy
February 15th, 2008, 03:10 PM
http://msdn2.microsoft.com/en-us/library/aa911940.aspx

And, what is the return value of "RegCreateKeyEx"? Did it succeed?

Viggy

brahmma
February 18th, 2008, 04:19 AM
Did you read the documentation? The first very parameter that you should supply RegSetValueEx should be a handle to an open registry key. I don't see you opening a key, but you are right out trying to set a value. Neither do you check if the call to RegSetValueEx succeeded. May be you should see a sample in MSDN which explains the usage of this call.

heteroy
February 21st, 2008, 11:51 PM
The 6th parameter of RegCreateKeyEx is the desired access mode. You are passing 0. Try using KEY_SET_VALUE.