MFC 获取系统类型及版本

CString GetSystemType(void)
{
	OSVERSIONINFO   osvi; 
	osvi.dwOSVersionInfoSize   =   sizeof(OSVERSIONINFO); 
	GetVersionEx(&osvi); 
	CString   csver; 
	switch   (osvi.dwPlatformId) 
	{ 
	case   VER_PLATFORM_WIN32_NT: 
		if   (   osvi.dwMajorVersion   ==   6   &&   osvi.dwMinorVersion   ==   1   ) 
			csver   =   "Windows 7 "; 
		if   (   osvi.dwMajorVersion   ==   5   &&   osvi.dwMinorVersion   ==   2   ) 
			csver   =   "Windows Server 2003 "; 
		if   (   osvi.dwMajorVersion   ==   5   &&   osvi.dwMinorVersion   ==   1   ) 
			csver   =   "Windows XP,"; 
		if   (   osvi.dwMajorVersion   ==   5   &&   osvi.dwMinorVersion   ==   0   ) 
			csver   =   "Windows 2000,"; 
		if   (   osvi.dwMajorVersion   <=   4   ) 
			csver   =   "Windows   NT   "; 
		csver   +=   osvi.szCSDVersion; 
		break; 

	case   VER_PLATFORM_WIN32_WINDOWS: 

		if   (osvi.dwMajorVersion   ==   4   &&   osvi.dwMinorVersion   ==   0) 
		{ 
			csver   =   "Windows   95   "; 
			if   (   osvi.szCSDVersion[1]   ==   'C '   ||   osvi.szCSDVersion[1]   ==   'B '   ) 
				csver   +=   "OSR2   "; 
		}   

		if   (osvi.dwMajorVersion   ==   4   &&   osvi.dwMinorVersion   ==   10) 
		{ 
			csver   =   "Windows   98   "; 
			if   (   osvi.szCSDVersion[1]   ==   'A '   ) 
				csver   +=   "SE   "; 
		}   

		if   (osvi.dwMajorVersion   ==   4   &&   osvi.dwMinorVersion   ==   90) 
		{ 
			csver   =   "Windows   Millennium   Edition "; 
		}   
		break; 

	case   VER_PLATFORM_WIN32s: 
		csver   =   "Win32s "; 
		break; 
	} 
	return csver;
}

你可能感兴趣的:(MFC 获取系统类型及版本)