获取windows操作系统版本

最新在项目中碰到了操作系统差异化的情况 需要做不同的处理

所以就必须得区别操作系统

代码如下

 

		OSVERSIONINFO Version;

		ZeroMemory(&Version,sizeof(OSVERSIONINFO));

		Version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

		GetVersionEx(&Version);	

		if (Version.dwPlatformId==VER_PLATFORM_WIN32_NT) 

		{

			if((Version.dwMajorVersion==5)&&(Version.dwMinorVersion==0))

			{

				return WIN2K;

			}else if((Version.dwMajorVersion==5)&&(Version.dwMinorVersion>0))

			{

				return WINXP;

			}else if((Version.dwMajorVersion==6)&&(Version.dwMinorVersion==0))

				return VISTA;

			else if((Version.dwMajorVersion>=6))

				return WIN7;

		}

		else if(Version.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)

		{

			if ((Version.dwMajorVersion == 4) && (Version.dwMinorVersion < 90) )

			{

				return WIN98;

			}

			if ((Version.dwMajorVersion == 4) && (Version.dwMinorVersion >= 90) )

			{

				return WINME;

			}

		}

		


 

 

你可能感兴趣的:(windows)