VC 获取操作系统版本信息

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 里面查看

posted @ 2011-11-23 14:11  曾经的碎片  阅读(1554)  评论(0编辑  收藏  举报