// RegCreateValue.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <tchar.h>#include <Windows.h>int main(int argc, char* argv[]){ HKEY hSubKey;//以KEY_SET_VALUE权限打开HKEY_CURRENT_USER\ Control Panel键的句柄 LONG ReturnValue = RegOpenKeyEx (HKEY_CURRENT_USER, "Control Panel", 0L, KEY_SET_VALUE, &hSubKey); DWORD dwValue = 0xff; if (ReturnValue == ERROR_SUCCESS) { ReturnValue = RegSetValueEx(hSubKey, "test", 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD)); if (ReturnValue == ERROR_SUCCESS) { printf("设置成功"); } else { printf("设置失败"); } } return 0;}