void CtestThreadDlg::OnBnClickedButton3() { HKEY hKey; DWORD dwType = REG_SZ; DWORD dwSize = 255;//须指定长度,否则第一次读取RegQueryValueEx不成功,仅返回长度 WCHAR data[MAX_PATH]; bool ret; if (RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\ CurrentVersion"), &hKey) == ERROR_SUCCESS) { TRACE(_T("未找到此键")); return; } ret = RegQueryValueEx(hKey, _T("ProductName"), NULL, & dwType, (LPBYTE)data, & dwSize) == ERROR_SUCCESS; RegCloseKey(hKey); ret = wcscmp(data, _T("Windows 10 Pro")) == 0; CString str; str.Format(_T("%d"), ret); TRACE(str); }
WIN10+VS2015编译通过.
原文地址:http://9233403.blog.51cto.com/9223403/1971125