#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
//操作注册表
HKEY key;
LPBYTE path_Get=new BYTE[254];
DWORD type =REG_SZ;
DWORD dwBytes = 254;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_READ, &key) == ERROR_SUCCESS)
{
printf("注册表打开成功\n");
// 查询注册表 值
if ( RegQueryValueEx(key, _T("hello"), 0, &type, path_Get, &dwBytes ) == ERROR_SUCCESS )
{
printf("存在\n");
}
else
{
printf("不存在\n");
}
}
//关闭键
RegCloseKey(key);
system("pause");
return 0;
}
使用 Unicode 字符集