Fandom

Delphi Programming

Windows Version (Code Snippet)

2,918pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Checking the windows version programmatically involves the following Global Variables (Unit: SysUtils):

On a Windows XP Service Pack 2 system that would give:

  • Win32Platform = VER_PLATFORM_WIN32_NT (constant)
  • Win32MajorVersion = 5 (integer)
  • Win32MinorVersion = 1 (integer)
  • Win32BuildNumber = 2600 (integer)
  • Win32CSDVersion = Service Pack 2 (string)

Combined NT 5.1.2600 'Service Pack 2'

ExampleEdit

TWindowsVersion = (wvUnknown, wvWin95, wvWin98, wvWin98SE, wvWinME, wvWinNT, 
                       wvWin2k, wvWinXP, wvWin2k3, wvVista, wvSeven);

function GetWindowsVersion: TWindowsVersion;
begin
  Result := wvUnknown;
  if Win32Platform = VER_PLATFORM_WIN32_NT then
    case Win32MajorVersion of
      4: Result := wvWinNT;
      5: case Win32MinorVersion of
           0: Result := wvWin2k;
           1: Result := wvWinXP;
           2: Result := wvWin2k3;
         end;
      6: case Win32MinorVersion of
           0: Result := wvVista;
           1: Result := wvSeven;
         end;
    end
  else
    case Win32MinorVersion of // No need to check Major on 9x, it is always 4
 type
      00: Result := wvWin95;
      10: if Trim(Win32CSDVersion) = 'A' then
            Result := wvWin98SE
          else
            Result := wvWin98;
      90: Result := wvWinME;
    end;
  end;
end;

See alsoEdit

External linksEdit


Code Snippets
DatabasesFiles and I/OForms/WindowsGraphicsNetworkingMath and AlgorithmsMiscellaneousMultimediaSystemVCL

Also on Fandom

Random Wiki