获取操作系统版本时如何区分2008 server和vista?
通过GetVersionEx获取系统版本时,2008 server和vista的主版本号和次版本号都是6、0.这样就无法区分是2008还是vista了!请问有没有别的办法来区分这两种操作系统?
CString CDialogInfo::GetSystemVersion(){ CString strVersion = ""; OSVERSIONINFOEX osvi; ZeroMemory(&osvi,sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(osvi); if (!GetVersionEx((OSVERSIONINFO*)&osvi)) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx((OSVERSIONINFO*)&osvi)) { return strVersion; } } //判断系统类型// char szTemp[MAX_PATH] = {0};// sprintf(szTemp,"PlatFormID:%d MajorVersion:%d MinorVersion:%d",osvi.dwPlatformId,osvi.dwMajorVersion,osvi.dwMinorVersion);// MessageBox(szTemp); switch(osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: if ( osvi.dwMajorVersion <= 4 ) strVersion += "winnt"; if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) strVersion += "win2000"; if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) strVersion += "winxp"; else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) strVersion += "win2003"; if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) strVersion += "vista"; break; case VER_PLATFORM_WIN32_WINDOWS: if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) strVersion += "win95"; if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) strVersion += "win98"; if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) strVersion += "winME"; break; case VER_PLATFORM_WIN32s: strVersion += "win32s"; break; } return strVersion;}