HKEY hKey; LPCTSTR lpValue = "Test Value"; LPCTSTR lpData = "This is a test data"; DWORD dwType = REG_SZ; DWORD dwSize = sizeof(lpData); if(RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\TestApp", 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { if(RegSetValueEx(hKey, lpValue, 0, dwType, (BYTE*)lpData, dwSize) == ERROR_SUCCESS) { printf("String Value '%s' Set Successfully", lpValue); } RegCloseKey(hKey); }
HKEY hKey; LPCTSTR lpValue = "Test Value"; DWORD dwType = REG_DWORD; DWORD dwData = 10; DWORD dwSize = sizeof(DWORD); if(RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\TestApp", 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { if(RegSetValueEx(hKey, lpValue, 0, dwType, (BYTE*)&dwData, dwSize) == ERROR_SUCCESS) { printf("Integer Value '%s' Set Successfully", lpValue); } RegCloseKey(hKey); }This example sets the value of a registry key named "Test Value" to an integer value of 10. Package library: Windows API In conclusion, CKey SetValue is a function in the Windows API package library used for setting the value of a key in a registry. It is commonly used in registry operations where keys need to be updated or changed.