BOOL CGetPCInfo::GetOsInfor(char* szOsName)
{
char szOsType[MAX_PATH];
HKEY hKey;
LPCTSTR StrKey="Software\\Microsoft\\Windows NT\\CurrentVersion";
if (ERROR_SUCCESS==::RegOpenKeyEx(HKEY_LOCAL_MACHINE,StrKey,NULL,KEY_ALL_ACCESS,&hKey))
{
DWORD dwSize = 255;
DWORD dwType = REG_SZ;
LPCSTR KeyValue = "ProductName";
if (ERROR_SUCCESS!=::RegQueryValueEx(hKey,KeyValue,0,&dwType,(BYTE *)szOsType,&dwSize))
{
return FALSE;
}
::RegCloseKey(hKey);
}
OSVERSIONINFO osVer;
osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (!::GetVersionEx (&osVer))
{
return FALSE;
}
sprintf(szOsName, "%s(%s)",szOsType,osVer.szCSDVersion);
return TRUE;
}
具体版本号可在 osVer 里面查看