Adding a new registry VALUE
-
Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.
-
Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.
Have a look at: http://www.codeproject.com/system/cregisterex_svl.asp http://www.codeproject.com/system/cregistrykey.asp
"Isn't that the "write once, debug everywhere" language?" Tom Archer on Java... :)
-
Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.
-
Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.
Hi, This will solve your problem. unsigned long ValueSize = 10; // you can use also sizeof ( long ) or anything you need. if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info , 0, KEY_READ|KEY_SET_VALUE, &hKey) != ERROR_SUCCESS ) { // error message. return; } RegSetValueEx(hKey,"Info",NULL,REG_SZ,(unsigned char*)5,ValueSize); Aizik Yair Software Engineer