Thema: Delphi OS auslesen

Einzelnen Beitrag anzeigen

michael.funcke

Registriert seit: 22. Apr 2011
9 Beiträge
 
Delphi 2010 Architect
 
#7

AW: OS auslesen

  Alt 23. Apr 2011, 17:20
Zitat:
Dir ist schon klar, dass ab Windiws2000 alles NT Systeme sind?
Nein, das war mir nicht klar. Danke.

Hab jetzt meine Lösung gefunden:
Code:
function TForm1.GetOperatingSystem(): String;
var
  osVerInfo: TOSVersionInfo;
  majorVer, minorVer: Integer;
begin
  osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  if GetVersionEx(osVerInfo) then
  begin
    majorVer := osVerInfo.dwMajorVersion;
    minorVer := osVerInfo.dwMinorVersion;
    case osVerInfo.dwPlatformId of
      // Windows NT/2000
      VER_PLATFORM_WIN32_NT:
        begin
          if majorVer <= 4 then
            Result := 'WinNT'
          else if (majorVer = 5) and (minorVer = 0) then
            Result := 'Win2000'
          else if (majorVer = 5) and (minorVer = 1) then
            Result := 'WinXP'
          else if (majorVer = 6) and (minorVer = 0) then
            Result := 'WinVista'
          else if (majorVer = 6) and (minorVer = 1) then
            Result := 'Win7'
          else
            Result := 'Unknown';
        end;
      // Windows 9x/ME
      VER_PLATFORM_WIN32_WINDOWS:
        begin
          if (majorVer = 4) and (minorVer = 0) then
            Result := 'Win95'
          else if (majorVer = 4) and (minorVer = 10) then
          begin
            if osVerInfo.szCSDVersion[1] = 'A' then
              Result := 'Win98SE'
            else
              Result := 'Win98';
          end
          else if (majorVer = 4) and (minorVer = 90) then
            Result := 'WinME'
          else
            Result := 'Unknown';
        end;
      else
        Result := 'Unknown';
    end;
  end
  else
    Result := 'Unknown';
end;
Danke euch!
  Mit Zitat antworten Zitat