Q: How can I write data to the registry?
A:
Code:HKEY hKey; if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Windows", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) { DWORD dwValue = 245; // Set value if(::RegSetValueEx(hKey, "NameOfValue", 0, REG_DWORD, reinterpret_cast<BYTE *>(&dwValue), sizeof(dwValue)) != ERROR_SUCCESS) { // Close key ::RegCloseKey(hKey); // Error handling; } // Close key ::RegCloseKey(hKey); } else // Error handling;