OSVERSIONINFO The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.typedef struct _OSVERSIONINFO{ DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; DWORD dwMinorVersion; DWORD dwBuildNumber; DWORD dwPlatformId; TCHAR szCSDVersion[ 128 ]; } OSVERSIONINFO; Members dwOSVersionInfoSize Specifies the size, in bytes, of this data structure. Set this member to sizeof(OSVERSIONINFO) before calling the GetVersionEx function. dwMajorVersion Identifies the major version number of the operating system as follows. Operating System Value Windows 95 4 Windows 98 4 Windows Me 4 Windows NT 3.51 3 Windows NT 4.0 4 Windows 2000 5 Windows XP 5 Windows .NET Server 5 dwMinorVersion Identifies the minor version number of the operating system as follows. Operating System Value Windows 95 0 Windows 98 10 Windows Me 90 Windows NT 3.51 51 Windows NT 4.0 0 Windows 2000 0 Windows XP 1 Windows .NET Server 1 dwBuildNumber Windows NT/2000/XP: Identifies the build number of the operating system. Windows 95/98/Me: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers. dwPlatformId Identifies the operating system platform. This member can be one of the following values. Value Platform VER_PLATFORM_WIN32s Win32s on Windows 3.1. VER_PLATFORM_WIN32_WINDOWS Windows 95, Windows 98, or Windows Me. VER_PLATFORM_WIN32_NT Windows NT 3.51, Windows NT 4.0, Windows 2000, Windows XP, or Windows .NET Server.
OSVERSIONINFO OsInfo;GetVersionEx(&OsInfo);OsInfo.dwPlatformId == VER_PLATFORM_WIN32s //Win32s on Windows 3.1. // VER_PLATFORM_WIN32_WINDOWS //Win32 on Windows 95 //or Windows 98. // VER_PLATFORM_WIN32_NT //Win32 on Windows NT. 你可以在你的这三个系统中调试, 看具体的值
The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.typedef struct _OSVERSIONINFO{
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[ 128 ];
} OSVERSIONINFO;
Members
dwOSVersionInfoSize
Specifies the size, in bytes, of this data structure. Set this member to sizeof(OSVERSIONINFO) before calling the GetVersionEx function.
dwMajorVersion
Identifies the major version number of the operating system as follows. Operating System Value
Windows 95 4
Windows 98 4
Windows Me 4
Windows NT 3.51 3
Windows NT 4.0 4
Windows 2000 5
Windows XP 5
Windows .NET Server 5
dwMinorVersion
Identifies the minor version number of the operating system as follows. Operating System Value
Windows 95 0
Windows 98 10
Windows Me 90
Windows NT 3.51 51
Windows NT 4.0 0
Windows 2000 0
Windows XP 1
Windows .NET Server 1
dwBuildNumber
Windows NT/2000/XP: Identifies the build number of the operating system.
Windows 95/98/Me: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers. dwPlatformId
Identifies the operating system platform. This member can be one of the following values. Value Platform
VER_PLATFORM_WIN32s Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS Windows 95, Windows 98, or Windows Me.
VER_PLATFORM_WIN32_NT Windows NT 3.51, Windows NT 4.0, Windows 2000, Windows XP, or Windows .NET Server.
// VER_PLATFORM_WIN32_WINDOWS //Win32 on Windows 95
//or Windows 98.
// VER_PLATFORM_WIN32_NT //Win32 on Windows NT. 你可以在你的这三个系统中调试, 看具体的值
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSVersionInfo);
if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && OSVersionInfo.dwMajorVersion == 5 && OSVersionInfo.dwMinorVersion == 0)
{
AfxMessageBox("Windows 2000 OS!");
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && OSVersionInfo.dwMajorVersion == 5 && OSVersionInfo.dwMinorVersion == 1)
{
AfxMessageBox("Windows XP OS !");
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && OSVersionInfo.dwMajorVersion == 4 && OSVersionInfo.dwMinorVersion == 0)
{
AfxMessageBox("Windows 98 OS!");
}