这里定义了一个Monitor,想要读取Flags的值为1
HKEY hOpen;
char key[255] = "SOFTWARE\\Monitor\\";
char name[10] = "Flags";
char buf[255];
DWORD size;
if(ERROR_SUCCESS==RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WOW64_64KEY, &hOpen))
{
RegQueryValueEx(hOpen, name, NULL, NULL, (BYTE*)buf, &size);
cout << buf << endl;
}
RegCloseKey(hOpen);
if(!strcmp("1", buf)){
return true;
}else{
return false;
}
64位系统 或上一个 KEY_WOW64_64KEY