[C++] 纯文本查看 复制代码
#include "stdafx.h"
#include <Windows.h>
#include <Winreg.h>
void Add_Key(HKEY hKey)
{
HKEY hSubKey;
DWORD dwKeyValue = 110;
RegCreateKey(hKey, TEXT("RegAdder"), &hSubKey);
if ( ERROR_SUCCESS != RegSetValueEx(hSubKey, TEXT("TEST"), NULL, REG_DWORD, (const byte*)&dwKeyValue, sizeof(DWORD))) {
printf ("Error\n");
}
}
int _tmain(int argc, _TCHAR* argv[])
{
HKEY hMyTestKey;
if ( RegOpenKeyEx ( HKEY_CURRENT_USER, TEXT("SOFTWARE"),
0, KEY_READ | KEY_WRITE,
&hMyTestKey) == ERROR_SUCCESS)
{
Add_Key(hMyTestKey);
}
return 0;
}