现在的位置: 首页 > 自动控制 > 工业·编程 > 正文

如何获取操作系统版本

2012-08-15 23:44 工业·编程 ⁄ 共 688字 ⁄ 字号 暂无评论

OSVERSIONINFO OSVersionInfo;
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSVersionInfo); 
if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT 
  && OSVersionInfo.dwMajorVersion == 5 
  && OSVersionInfo.dwMinorVersion == 0)
{
  //AfxMessageBox("Windows 2000 OS!");
  cout << "Windows 2000 OS!" << endl;
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT 
  && OSVersionInfo.dwMajorVersion == 5 
  && OSVersionInfo.dwMinorVersion == 1)
{
  //AfxMessageBox("Windows XP OS !");
  cout << "Windows XP OS !" << endl;
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS 
  && OSVersionInfo.dwMajorVersion == 4 
  && OSVersionInfo.dwMinorVersion == 0)
{
  //AfxMessageBox("Windows 98 OS!");
  cout << "Windows 98 OS!" << endl;
}

给我留言

留言无头像?