#include <windows> #include <string.h> int main(int argc, char* argv[]) { HKEY hKey; DWORD dwType = REG_SZ; DWORD dwSize = 255; //须指定长度,否则第一次读取RegQueryValueEx不成功,仅返回长度 char data[MAX_PATH]; bool ret; //打开主键 if(RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey) == ERROR_SUCCESS) cout << "open register success" <<endl; //读取键值 ret = RegQueryValueEx(hKey,"ProductName", NULL, &dwType, (LPBYTE)data, &dwSize) == ERROR_SUCCESS; //关闭主键 RegCloseKey(hKey); ret = strcmp(data, "Microsoft Windows XP") == 0; if(ret) { cout << "当前操作系统为xp:" <<endl; } cout << data << endl; getchar(); return 0; }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。