Sorry to ask another newbie question so soon, but this is completely driving me nuts. I want to set a registry value to a number. Here is the code:
This does absolutely nothing... The weird part is it doesn't even return an error so I can't tell what I did wrong, and none of the example code I've been able to turn up has told me anything useful. Another weird thing, if I make the code:Code:RegSetValueEx( hKey, "/*Name of value*/", 0, REG_DWORD, (const BYTE *) 1, sizeof(DWORD));
it works, but it's the ASCII value for "1" and not the number 1. I tried to do this with the char(1) too, but that produced the same result as just 1. I really can't figure out what's going on here, so I need some help. Also my code for querying a registry value doesn't seem to work either, and since the problems are probobly related I'll post that code too:Code:RegSetValueEx( hKey, "/*Name of value*/", 0, REG_DWORD, (const BYTE *) "1", sizeof(DWORD));
No matter what, this always prints 0. I'm resonably sure my hKey value is correct, otherwise I wouldn't have been able to set string data successfully, but just in case here's that code too:Code:LPBYTE registryDataReturn = 0; LPDWORD registryDataSize = 0; RegQueryValueEx( hKey, "/*Any value within the current key*/", 0, NULL, registryDataReturn, registryDataSize); printf("%d\n", (int) registryDataReturn);
If you can shed any light on this whole mess, I'd really appreciate it.Code:RegCreateKeyEx( HKEY_CURRENT_USER, "/*Registry key here */", 0, (LPTSTR) NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, (LPSECURITY_ATTRIBUTES) NULL, &hKey, (LPDWORD) NULL);



LinkBack URL
About LinkBacks


