Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Windows Version inkl. Win 11 ermitteln (https://www.delphipraxis.net/217806-windows-version-inkl-win-11-ermitteln.html)

Walter Landwehr 10. Sep 2025 13:14

Windows Version inkl. Win 11 ermitteln
 
Hallo kennt jemand eine function die sauber die Windows Version zurück gibt.

Danke für jeden Tipp im voraus.

fred42 10. Sep 2025 16:05

AW: Windows Version inkl. Win 11 ermitteln
 
Hallo,
ueber WMI

https://www.delphipraxis.net/215190-...mitteln-3.html

Gruß

Kas Ob. 11. Sep 2025 08:54

AW: Windows Version inkl. Win 11 ermitteln
 
Hi,
Zitat:

Zitat von Walter Landwehr (Beitrag 1551639)
Hallo kennt jemand eine function die sauber die Windows Version zurück gibt.

Danke für jeden Tipp im voraus.

Here a trick that can't be fooled by Windows Compatibility, that work for 32bit and 64bit.

Delphi-Quellcode:
type
  TWinVersion = record
    Major: Cardinal;
    Minor: Cardinal;
  end;

function GetWinVersion: TWinVersion;
const
  // Address of USER_SHARED_DATA (KUSER_SHARED_DATA) is always at FS/GS:[0x7FFE0000]
  KUSER_SHARED_DATA = $7FFE0000;
begin
  // NtMajorVersion is at offset $26C, NtMinorVersion at $270
  // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
  Result.Major := PCardinal(KUSER_SHARED_DATA + $26C)^;
  Result.Minor := PCardinal(KUSER_SHARED_DATA + $270)^;
end;
As for build number is little more trickier and while it is backward compatible, there is no guarantee it will work in future, but you can access the build number by reading NtBuildNumber, whcih changed its index in the past.
Zitat:

0x0244 (4.0 to 5.1);
0x0248 (5.2 to 6.1);
0x0260

Cypheros 11. Sep 2025 11:05

AW: Windows Version inkl. Win 11 ermitteln
 
Nice :)

himitsu 11. Sep 2025 12:07

AW: Windows Version inkl. Win 11 ermitteln
 
Feste Speicheradresse?

Zum Glück ist ASLR in aktuellen Delphis nicht aktiv.
Halt nee, ist es. :stupid:

Kas Ob. 11. Sep 2025 15:04

AW: Windows Version inkl. Win 11 ermitteln
 
Zitat:

Zitat von himitsu (Beitrag 1551721)
Feste Speicheradresse?

Zum Glück ist ASLR in aktuellen Delphis nicht aktiv.
Halt nee, ist es. :stupid:

That address belong to a magic read-only fixed page, it is there since the dawn of Windows 32bit, and it is not going anywhere anytime, also documented my Microsoft, the thing is the documentation went from mainstream to more less encouraged to be used, but it was heavily documented in DDK and not only that it was recommended to be relied on for timing instead of GetTickCount for games and more specially for low level drivers.
https://learn.microsoft.com/en-us/wi...er_shared_data
https://learn.microsoft.com/en-us/wi...gercmds/-kuser

In case you afraid of ASLR, which doesn't have a connection to non executable loading address as it is read-only page for general information, then have a look at this
https://msrc.microsoft.com/blog/2022...re-on-windows/
meaning for User space the address and that page will stay the same,
and for Driver/Kernel space where it is read+write it might be change address on boot when KASLR is enabled.

kopernikus 11. Sep 2025 21:49

AW: Windows Version inkl. Win 11 ermitteln
 
Es gibt eine fertige Unit auf GitHub

FriedrichAT 12. Sep 2025 00:30

AW: Windows Version inkl. Win 11 ermitteln
 
Hallo habe hier etwas gefunden - WMI

Delphi-Quellcode:
Uses System.Win.ComObj, WinApi.ActiveX;

function WMI_Get_Betriebssystem(const Mit_Version: Boolean = False): String;
const
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator: OLEVariant;
  FWMIService: OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject: OLEVariant;
  iEnum: IEnumvariant;
  iValue: Cardinal;
begin
  Result := '?';
  try
    FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
    FWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
    FWbemObjectSet := FWMIService.ExecQuery('SELECT Name, Version FROM Win32_OperatingSystem',
                                            'WQL', wbemFlagForwardOnly);
    iEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumvariant;

    if iEnum.Next(1, FWbemObject, iValue) = 0 then
    begin
      Result := String(FWbemObject.Name);
      if Pos('|', Result) > 0 then
        Result := Copy(Result, 1, Pos('|', Result) - 1);

      if Pos('Microsoft ', Result) > 0 then
        Try
          Result := Trim(Copy(Result, Pos('Microsoft ', Result) + 10, 40));
        except
        end;

      if Mit_Version then
        Result := Result + ' [ ' + String(FWbemObject.Version) + ' ]';

      FWbemObject := Unassigned;
    end;
  except
    try
      Result := WMI_Get_Betriebssystem;
    except
      Result := '?';
    end;
  end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  try
    CoInitialize(nil);
    try
      Memo1.Lines.Add(WMI_Get_Betriebssystem(False));
    finally
      CoUninitialize;
    end;
  except
    on E:EOleException do Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
    on E:Exception do Writeln(E.Classname, ':', E.Message);
  end;
  // Ausgabe: Windows 11 Pro
  try
    CoInitialize(nil);
    try
      Memo1.Lines.Add(WMI_Get_Betriebssystem(True));
    finally
      CoUninitialize;
    end;
  except
    on E:EOleException do Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
    on E:Exception do Writeln(E.Classname, ':', E.Message);
  end;
  // Ausgabe: Windows 11 Pro [ 10.0.26100 ]
end;
Ausgabe:
Windows 11 Pro
Windows 11 Pro [ 10.0.26100 ]

DaCoda 13. Sep 2025 08:51

AW: Windows Version inkl. Win 11 ermitteln
 
Liste der Anhänge anzeigen (Anzahl: 1)
Diese Unit beinhaltet alles was man braucht. Hab ich mal irgendwo gefunden und nutze die schon ewig zum ermitteln von Systeminformationen.
Vielleicht ist das ja auch was für Euch...

blawen 13. Sep 2025 12:58

AW: Windows Version inkl. Win 11 ermitteln
 
Zitat:

Zitat von DaCoda (Beitrag 1551796)
Diese Unit beinhaltet alles was man braucht. Hab ich mal irgendwo gefunden und nutze die schon ewig zum ermitteln von Systeminformationen.
Vielleicht ist das ja auch was für Euch...

Das "Original" stammt vermutlich von hier DelphiDabbler


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:03 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz