#include <stdio.h>
#include <windows.h>
//OSVERSIONINFO???????壺
//
//typedef OSVERSIONINFOW OSVERSIONINFO;
//typedef struct _OSVERSIONINFOW {
//    DWORD dwOSVersionInfoSize;    //????????????????С
//    DWORD dwMajorVersion;        //???????????汾??   5????2000????汾
//    DWORD dwMinorVersion;       //??????????汾??    0????win2000. 1????winxp
//    DWORD dwBuildNumber;       //?????????????
//    DWORD dwPlatformId;         //??????ID??
//    WCHAR szCSDVersion[ 128 ];     // Maintenance string for PSS usage    ?????????????Щ???????
//} OSVERSIONINFOW?? *POSVERSIONINFOW?? *LPOSVERSIONINFOW?? RTL_OSVERSIONINFOW?? *PRTL_OSVERSIONINFOW;
int GetOSVer()
{
OSVERSIONINFO   osver;
osver.dwOSVersionInfoSize   =   sizeof(OSVERSIONINFO);
GetVersionEx(&osver);
if(osver.dwPlatformId == 2)
{
if(osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1)
{
printf("xp ");
return(2);
}
if(osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2)
{
printf("windows 2003 ");
return(3);
}
if(osver.dwMajorVersion ==  6 && osver.dwMinorVersion == 0)
{
printf("vista and 2008 ");
return(4);
}
if(osver.dwMajorVersion ==  6 && osver.dwMinorVersion == 1)
{
printf("2008 R2 and Windows 7 ");
return(5);
}
}
return 0;
}
int main()
{
GetOSVer();
system("pause");
}