-
February 7th, 2006, 05:47 AM
#1
Working with registry functions
Hi all,
I'm experimenting with the registry functions, i can create en new key but can't seem to add data to a key, what am im doing wrong ?
Code:
HKEY hKey;
DWORD dwSize=MAX_PATH;
struct resbuf *args = NULL;
char *Path;
char *Key;
char *Value;
DWORD dwType=0;
char str[256];
DWORD dwDisp = 0;
LPDWORD lpdwDisp = &dwDisp;
if (RegCreateKeyEx (HKEY_CURRENT_USER, Path, 0, NULL,0,0,NULL, &hKey, lpdwDisp) == ERROR_SUCCESS)
{
/// till here it works
if (RegSetValueEx(hKey, Key, 0, REG_SZ, Value, sizeof(Value))== ERROR_SUCCESS)
{
fdt_rett();
}
else
{
fdt_retnil();
}
}
else
{
fdt_retnil();
}
-
February 7th, 2006, 05:55 AM
#2
Re: Working with registry functions
RegCreateKeyEx (HKEY_CURRENT_USER, Path, 0, NULL,0,0,NULL, &hKey, lpdwDisp)
Modify the above to this...
RegCreateKeyEx (HKEY_CURRENT_USER, Path, 0, NULL, 0, KEY_SET_VALUE, NULL, &hKey, lpdwDisp)
Take a look in MSDN for further details...
-
February 7th, 2006, 06:41 AM
#3
Re: Working with registry functions
Great ! it works thank you !!!!
-
February 7th, 2006, 07:38 AM
#4
Re: Working with registry functions
You have another bug in your code in this line:
Code:
if (RegSetValueEx(hKey, Key, 0, REG_SZ, Value,sizeof(Value))== ERROR_SUCCESS)
Value is declared as a pointer hence the sizeof will return 4 bytes so you wont be able to write string longer than that.
look in the FAQ for more info: How can I write data to the registry?.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|