怎么得到呢,从网上查到只有检测98,2000,xp的
其他的几个版本怎么得到检测呢

解决方案 »

  1.   

    #include <windows.h > 
    #include <tchar.h > 
    #include <stdio.h > 
    #define BUFSIZE 80 
    typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); 
    int _tmain() 

    OSVERSIONINFOEX osvi; 
    SYSTEM_INFO si; 
    PGNSI pGNSI; 
    BOOL bOsVersionInfoEx; ZeroMemory(&si, sizeof(SYSTEM_INFO)); 
    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); 
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) 

    osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); 
    if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
    return FALSE; 

    pGNSI = (PGNSI) GetProcAddress( 
    GetModuleHandle(TEXT( "kernel32.dll ")), 
    "GetNativeSystemInfo "); 
    if(NULL != pGNSI) 
    pGNSI(&si); 
    else GetSystemInfo(&si); switch (osvi.dwPlatformId) 

    case VER_PLATFORM_WIN32_NT: 
    if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) 

    if( osvi.wProductType == VER_NT_WORKSTATION ) 
    printf ( "Windows Vista "); 
    else printf ( "Windows Server \ "Longhorn\ " " ); 
    } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) 

    if( GetSystemMetrics(SM_SERVERR2) ) 
    printf( "Microsoft Windows Server 2003 \ "R2\ " "); 
    else if( osvi.wProductType == VER_NT_WORKSTATION && 
    si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) 

    printf( "Microsoft Windows XP Professional x64 Edition "); 

    else printf ( "Microsoft Windows Server 2003, "); 
      

  2.   

    VISTA最大的特点是,你每做一件事老是问你,而老版本的就不会这样,不用什么检测,自己都知道的
      

  3.   

    #include <windows.h > 
    #include <tchar.h > 
    #include <stdio.h 
    #define BUFSIZE 80 
    typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
    BOOL WVMain()
    {
    OSVERSIONINFOEX osvi; 
    SYSTEM_INFO si; 
    PGNSI pGNSI; 
    BOOL bOsVersionInfoEx;  ZeroMemory(&si, sizeof(SYSTEM_INFO)); 
    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); 
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);  if( !(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi)) ) 

    osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); 
    if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
    return FALSE; 
    } pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT( "kernel32.dll ")), "GetNativeSystemInfo "); 
    if(NULL != pGNSI) 
    pGNSI(&si); 
    else 
    GetSystemInfo(&si);  switch (osvi.dwPlatformId) 

    case VER_PLATFORM_WIN32_NT: 
    if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) 

    if( osvi.wProductType == VER_NT_WORKSTATION ) 
    printf ( "Windows Vista "); 
    else 
    printf ( "Windows Server \"Longhorn\"\n" ); 
    }  if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) 

    if( GetSystemMetrics(SM_SERVERR2) ) 
    printf( "Microsoft Windows Server 2003 \"R2\"\n"); 
    else if( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) 

    printf( "Microsoft Windows XP Professional x64 Edition\n"); 

    else printf ( "Microsoft Windows Server 2003\n"); 
    } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) 
    {
    printf("The operating system is Windows XP\n");
    }
    break;
    }
    return TRUE;}dwMajorVersion 
    The major version number of the operating system. This member can be one of the following values.Value Meaning 
    4
     The operating system is Windows NT 4.0.
     
    5
     The operating system is Windows Server 2003 R2, Windows Server 2003, Windows XP, or Windows 2000.
     
    6
     The operating system is Windows Vista or Windows Server 2008.
     dwMinorVersion 
    The minor version number of the operating system. This member can be one of the following values.Value Meaning 
    0
     The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.
     
    1
     The operating system is Windows XP.
     
    2
     The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
     
      

  4.   

    调用GetVersionEx函数,返回的结构中,dwPlatformId用于区分9x和NT系列,dwMajorVersion和dwMinorVersion区分版本号。2000是5、0,XP是5、1,Vista是6、0。详见MSDN:
    http://msdn.microsoft.com/en-us/library/ms724451(VS.85).aspx