void CGetInfoDlg::GetOSInfo()
{
// TODO: 在此处添加实现代码.
HKEY hKey;
LPCTSTR subKey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
TCHAR productName[MAX_PATH], userName[MAX_PATH], systemRoot[MAX_PATH], currentType[MAX_PATH], currentVersion[MAX_PATH];
DWORD valueSize = MAX_PATH;
if (RegQueryValueExW(hKey, _T("ProductName"), NULL, NULL, (LPBYTE)productName, &valueSize) == ERROR_SUCCESS)
{
CString strProductName(productName);
CString productname(_T("windows 名称:"));
m_windowName.SetWindowTextW(productname + strProductName);
}
valueSize = MAX_PATH;
if (RegQueryValueExW(hKey, _T("RegisteredOwner"), NULL, NULL, (LPBYTE)userName, &valueSize) == ERROR_SUCCESS)
{
CString struserName(userName);
CString username(_T("用户名:"));
m_userName.SetWindowTextW(username + struserName);
}
valueSize = MAX_PATH;
if (RegQueryValueExW(hKey, _T("SystemRoot"), NULL, NULL, (LPBYTE)systemRoot, &valueSize) == ERROR_SUCCESS)
{
CString strsystemRoot(systemRoot);
CString systemroot(_T("windows 名称:"));
m_systemIn.SetWindowTextW(systemroot + strsystemRoot);
}
valueSize = MAX_PATH;
if (RegQueryValueExW(hKey, _T("CurrentType"), NULL, NULL, (LPBYTE)currentType, &valueSize) == ERROR_SUCCESS)
{
CString strcurrentType(currentType);
CString currenttype(_T("当前类型:"));
m_currentType.SetWindowTextW(currenttype + strcurrentType);
}
valueSize = MAX_PATH;
if (RegQueryValueExW(hKey, _T("CurrentVersion"), NULL, NULL, (LPBYTE)currentVersion, &valueSize) == ERROR_SUCCESS)
{
CString strcurrentVersion(currentVersion);
CString currentversion(_T("当前版本:"));
m_currentVison.SetWindowTextW(currentversion + strcurrentVersion);
}
RegCloseKey(hKey);
}
}