DWORD dwVersion = GetVersion();
// DWORD dwBuild;

// Get major and minor version numbers of Windows
DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get build numbers for Windows NT or Win32s
if(dwWindowsMajorVersion > 5 || (dwWindowsMajorVersion == 5 && dwWindowsMinorVersion > 0)) //winxp
{
          }请问dwWindowsMajorVersion这个值是如何分布的?
当为WIN98==?  WIN2000==?  WINNT==? WINME==?

解决方案 »

  1.   

    你查一查msdn 就知道了
     这个我用过,但记不住,
      

  2.   

    msdn  上只看到win98 win95 其它的我太清楚
      

  3.   

    GetVersionEx
    The GetVersionEx function obtains extended information about the version of the operating system that is currently running.Windows 2000: To compare the current system version to a required version, use the VerifyVersionInfo function instead of using GetVersionEx to perform the comparison yourself. BOOL GetVersionEx(
      LPOSVERSIONINFO lpVersionInfo // version information
    );
    Parameters
    lpVersionInfo 
    [in/out] Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information. 
    Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO). Windows 2000: This member can be a pointer to an OSVERSIONINFOEX structure. Set the dwOSVersionInfoSize member to sizeof(OSVERSIONINFOEX) to identify the structure type. Return Values
    If the function succeeds, the return value is a nonzero value.If the function fails, the return value is zero. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure. Res
    When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test:osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
    GetVersionEx (&osvi);
    bIsWindows98orLater = 
       (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
       ( (osvi.dwMajorVersion > 4) ||
       ( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) );
    Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself. For more information, see Operating System Version. 
      

  4.   


    Windows NT 3.51 0 Build number 3 
    Windows NT 4.0 0 Build number 4 
    Windows 2000 or Whistler 0 Build number 5 
    Windows 95, Windows 98, or Windows Me 1  Reserved 4 
    Win32s with Windows 3.1 1 Build number 3 
    dwVersion = GetVersion();
     
    // Get the Windows version.dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
    dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));// Get the build number.if (dwVersion < 0x80000000)              // Windows NT/2000, Whistler
        dwBuild = (DWORD)(HIWORD(dwVersion));
    else if (dwWindowsMajorVersion < 4)      // Win32s
        dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
    else                                     // Windows 95/98/Me
        dwBuild =  0;
      

  5.   

    有一组宏可以使用_osver, _winmajor, _winminor, _winver,具体的使用方法查一下MSDN