DelphiFAQ Home Search:

Determine what version of Windows a PC is running

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Do you need to determine what version of Windows a PC is running? The following code will work on all (Windows) platforms with Delphi 1 (16 bit) to Delphi 5 (32 bit).

It will distinguish between Windows 2000, NT, Windows 98, 95 and even Windows 3.1/ Windows for Workgroups.

function WinSystem : String;
var
  OSVersion : TOSVersionInfo;
  WinVersion: String;
  OrdHigh   : DWORD;
  OrdLow    : DWORD;
begin 
  OSVersion.dwOSVersionInfoSize := sizeof(OSVersion); 
  GetVersionEx(OSVersion); 
  OrdHigh := (OSVersion.dwBuildNumber shr 24) and $FF; 
  OrdLow := (OSVersion.dwBuildNumber shr 16) and $FF; 
  
  if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_NT then 
  begin 
    if (OrdHigh>=5) then 
    begin 
      WinVersion := 'Windows 2000' 
    end 
    else 
    begin 
      WinVersion := 'Windows NT' 
    end; 
  end; 
  if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then 
  begin 
    if (OrdLow>=90) or (OrdHigh>=5) then 
    begin 
      WinVersion := 'Windows Millennium' 
    end; 
    if (OrdLow>=10) and (OrdLow<90) then 
    begin 
      WinVersion := 'Windows 98' 
    end; 
    if (OrdLow<10) then 
    begin 
      WinVersion := 'Windows 95' 
    end; 
    if (OrdLow<5) then
    begin 
      WinVersion := 'Windows 3.1/ WfWg' 
    end;   
  end; 
  
  Result := WinVersion;
end;
You don't like the formatting? Check out SourceCoder then!

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.