Wikia

Delphi Programming

Windows Version (Code Snippet)

2,918pages on
this wiki
Talk0

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

Around Wikia's network

Random Wiki