Reg Keys

Started by
2 comments, last by Drew_Benton 18 years, 11 months ago
Could somone give an example or explain how to add/modify/delete a registration key using c++?
Advertisement
HKEY hKey;DWORD dwCount;   // Open key   if(RegOpenKeyEx(HKEY_CURRENT_USER,      "Software\\Something\\Something else\\",0,KEY_READ,&hKey) != ERROR_SUCCESS)      return false;   // Error   // Or, create a key:   if(RegCreateKey(HKEY_CURRENT_USER,      "Software\\Something\\Something else\\",&hKey) != ERROR_SUCCESS)      return false;   // Read a setting   dwCount = 4;   RegQueryValueEx(hKey,"Some Setting",NULL,NULL,(LPBYTE)&rSettings.dwMaxParticles,&dwCount);   // Write a setting   RegSetValueEx(hKey,"Some Other Setting",0,REG_DWORD,(LPBYTE)&rSettings.dwMaxParticles,sizeof(DWORD));   // Delete a setting:   RegDeleteValue(hKey,"Yet Another Setting");   // Delete a key:   RegDeleteKey(HKEY_CURRENT_USER,"Software\\Something\\Something else\\");

RegCreateKey will open the key if it already exists.

Edit: Added deleting a key/value
Thank you, works perfectly.
Quote:Original post by Evil Steve
*** Source Snippet Removed ***
RegCreateKey will open the key if it already exists.

Edit: Added deleting a key/value


Very nice [smile].

This topic is closed to new replies.

Advertisement