读文本型:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
HKEY hOpen;
char key[255] = "SOFTWARE\\Microsoft\\Internet Explorer\\URL Compatibility";
char name[10] = "Version";
char buf[255];
DWORD size;
if(ERROR_SUCCESS==RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hOpen))
{
RegQueryValueEx(hOpen, name, NULL, NULL, (BYTE*)buf, &size);
cout << buf << endl;
}
RegCloseKey(hOpen);
Sleep(3000);
return 0;
}
读数值型:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
HKEY hOpen;
char key[255] = "SOFTWARE\\Microsoft\\Internet Explorer\\URL Compatibility";
char name[10] = "Version";
DWORD buf = 0;
DWORD size = sizeof(buf);
if(ERROR_SUCCESS==RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hOpen))
{
RegQueryValueEx(hOpen, name, NULL, NULL, (LPBYTE*)buf, &size);
cout << buf << endl;
}
RegCloseKey(hOpen);
Sleep(3000);
return 0;
}