Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#7

AW: Abfrage der Windowsversion nach Update

  Alt 26. Mai 2022, 15:20
Hallo,

zu #4

Delphi-Quellcode:
procedure GetCIM_OperatingSystemInfo;
 const
    WbemUser = '';
    WbemPassword = '';
    WbemComputer = 'localhost';
    wbemFlagForwardOnly = $00000020;
  var
    FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject: OLEVariant;
    oEnum: IEnumvariant;
    iValue: LongWord;
  begin
    FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
    FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
    FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM CIM_OperatingSystem', 'WQL', wbemFlagForwardOnly);
    oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumvariant;

    while oEnum.Next(1, FWbemObject, iValue) = 0 do

    begin
      showmessage(Format('Caption %s', [string(FWbemObject.Caption)]));
      showmessage(Format('Version %s', [string(FWbemObject.Version)]));
      FWbemObject := Unassigned;
    end;
  end;
liefert bei Windows 11:

Caption: Windows 11 Pro
Version: 10.0.22000

https://theroadtodelphi.com/


Gruß
Danke. Dann wäre WMI also eine alternative. Davon bin ich ausgegangen.
  Mit Zitat antworten Zitat