判斷Windows版本號 (轉)

worldblog發表於2007-12-07
判斷Windows版本號 (轉)[@more@]

:GetVersionEx()
void __fastcall TForm1::FormCreate(T *Sender)
{
  OSVERSIONINFO info ;
  info.dwOSVersionInfoSize = sizeof (info) ;
  GetVersionEx (&info) ;

  switch (info.dwPlatfod)
  {
  case VER_PLATFORM_s:
    Label1->Caption = "System:  Win 32s" ;
    break ;
  case VER_PLATFORM_WIN32_WINDOWS:
    Label1->Caption = "System:  Windows 95" ;
    break ;
  case VER_PLATFORM_WIN32_NT:
    Label1->Caption = "System:  " ;
    break ;
  default:
    Label1->Caption = "System:  Unknown" ;
    break ;
  }

  Label2->Caption = String ("Version: ")
    + String ((int) info.dwMajorVersion) + "." + String((int)info.dwMinorVersion) ;
  Label3->Caption = String ("Build:  ") + String ((int) (info.dwBuildNumber & 0xFFFF)) ;
  Label4->Caption = String ("System Info:  ) + info.szCSDVersion + " ;
}
或者

The following code fragment illustrates how to extract information from the GetVersion return value:

 
dwVersion = GetVersion();

// Get major and minor version numbers of Windows

dwWindowsMajorVersion =  (D)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));

// Get build numbers for Windows NT or Win32s

if (dwVersion < 0x80000000)                // Windows NT
    dwBuild = (DWORD)(HIWORD(dwVersion));
else if (dwWindowsMajorVersion < 4)        // Win32s
    dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
else        // Windows 95 -- No build numbers provd

    dwBuild =  0;

 

 

 

 

 

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-989364/,如需轉載,請註明出處,否則將追究法律責任。

相關文章