Thema: Delphi OS auslesen

Einzelnen Beitrag anzeigen

Roy Altenau

Registriert seit: 7. Okt 2015
3 Beiträge
 
#11

AW: OS auslesen

  Alt 10. Okt 2015, 08:41
Delphi-Quellcode:
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] = 'Athen
              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;
Bei diesen Code bekomme ich unter Windows7 (XP als Ergebnis
  Mit Zitat antworten Zitat