Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

System Information

How do I determine the Windows OS version? by Stretchwickster
Posted: 25 Feb 03 (Edited 4 Dec 07)

This is a revised version of the previous code I was displaying here, but now includes Windows Vista detection. Most of the credit should go to Brian Long (of The Delphi Magazine) who wrote a short article regarding Windows Versions (source at the bottom of the page).

This revised FAQ replaces the GetVersionEx API call with the Delphi RTL global variables: Win32Platform, Win32MajorVersion, Win32MinorVersion, Win32BuildNumber and Win32CSDVersion (all of which can be found in the SysUtils unit of Delphi). If you want to see how these variables are assigned then go to the InitPlatformId procedure of SysUtils. It now identifies Windows 95 OSR2 and Windows 98 SE as well as Service Pack information for the NT family of Operating Systems. I have included some information about Win32CSDVersion as a comment in the code.


function GetOS: String;
// *** Information about Win32CSDVersion ***
// In the Win 9x family, Win32CSDVersion detects Win 95 OSR2 and Win 98 SE
// In the Win NT family, Win32CSDVersion detects Service Pack information
// CSD is an acronym for Corrective Service Disk
  PlatformId, VersionNumber: string;
  CSDVersion: String;
  CSDVersion := '';

  // Detect platform
  case Win32Platform of
    // Test for the Windows 95 product family
      if Win32MajorVersion = 4 then
        case Win32MinorVersion of
          0:  if (Length(Win32CSDVersion) > 0) and
                 (Win32CSDVersion[1] in ['B', 'C']) then
                PlatformId := '95 OSR2'
                PlatformId := '95';
          10: if (Length(Win32CSDVersion) > 0) and
                 (Win32CSDVersion[1] = 'A') then
                PlatformId := '98 SE'
                PlatformId := '98';
          90: PlatformId := 'ME';
        PlatformId := '9x version (unknown)';
    // Test for the Windows NT product family
      if Length(Win32CSDVersion) > 0 then CSDVersion := Win32CSDVersion;
      if Win32MajorVersion <= 4 then
        PlatformId := 'NT'
        if Win32MajorVersion = 5 then
          case Win32MinorVersion of
            0: PlatformId := '2000';
            1: PlatformId := 'XP';
            2: PlatformId := 'Server 2003';
        else if (Win32MajorVersion = 6) and (Win32MinorVersion = 0) then
          PlatformId := 'Vista'
          PlatformId := 'Future Windows version (unknown)';
  VersionNumber := Format(' Version %d.%d Build %d %s', [Win32MajorVersion,
  Result := 'Microsoft Windows ' + PlatformId + VersionNumber;

Revised Version:

"Windows Versions", The Delphi Clinic by Brian Long, The Delphi Magazine Issue 95 (July 2003)
Original Version:

Back to Embarcadero: Delphi FAQ Index
Back to Embarcadero: Delphi Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close