//-----------------------------------------------------------------------------------------------------
// This code was generated by the Wmi Delphi Code Creator http://theroadtodelphi.wordpress.com
// Version: 1.8.3.0
// LIABILITY DISCLAIMER
// THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.
// YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS,
// DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE.
//----------------------------------------------------------------------------------------------------
program GetWMI_Info;
{$APPTYPE CONSOLE}
uses
(* SysUtils, ActiveX, ComObj, Variants; *)
System.SysUtils,
Winapi.ActiveX,
System.Win.ComObj,
System.Variants;
function VarToInt(
const AVariant: Variant): INT64;
// integer;
begin Result := StrToIntDef(Trim(VarToStr(AVariant)), 0);
end;
// Die Klasse "Win32_USBHub" stellt die Verwaltungseigenschaften eines USB-Hubs dar.
procedure GetWin32_USBHubInfo;
const
WbemUser ='
';
WbemPassword ='
';
WbemComputer ='
localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator : OLEVariant;
FWMIService : OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
j : Integer;
begin;
FSWbemLocator := CreateOleObject('
WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, '
root\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet:= FWMIService.ExecQuery('
SELECT * FROM Win32_USBHub','
WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0
do
begin
Writeln(Format('
Availability %d',[VarToInt(FWbemObject.Availability)]));
// Uint16
Writeln(Format('
Caption %s',[VarToStr(FWbemObject.Caption)]));
// String
Writeln(Format('
ClassCode %d',[VarToInt(FWbemObject.ClassCode)]));
// Uint8
Writeln(Format('
ConfigManagerErrorCode %d',[VarToInt(FWbemObject.ConfigManagerErrorCode)]));
// Uint32
Writeln(Format('
ConfigManagerUserConfig %s',[VarToStr(FWbemObject.ConfigManagerUserConfig)]));
// Boolean
Writeln(Format('
CreationClassName %s',[VarToStr(FWbemObject.CreationClassName)]));
// String
// Writeln(Format('CurrentAlternateSettings %d',[VarToInt(FWbemObject.CurrentAlternateSettings)]));// Array of Uint8
Writeln(Format('
CurrentConfigValue %d',[VarToInt(FWbemObject.CurrentConfigValue)]));
// Uint8
Writeln(Format('
Description %s',[VarToStr(FWbemObject.Description)]));
// String
Writeln(Format('
DeviceID %s',[VarToStr(FWbemObject.DeviceID)]));
// String
Writeln(Format('
ErrorCleared %s',[VarToStr(FWbemObject.ErrorCleared)]));
// Boolean
Writeln(Format('
ErrorDescription %s',[VarToStr(FWbemObject.ErrorDescription)]));
// String
Writeln(Format('
GangSwitched %s',[VarToStr(FWbemObject.GangSwitched)]));
// Boolean
Writeln(Format('
InstallDate %s',[VarToStr(FWbemObject.InstallDate)]));
// Datetime
Writeln(Format('
LastErrorCode %d',[VarToInt(FWbemObject.LastErrorCode)]));
// Uint32
Writeln(Format('
Name %s',[VarToStr(FWbemObject.
Name)]));
// String
Writeln(Format('
NumberOfConfigs %d',[VarToInt(FWbemObject.NumberOfConfigs)]));
// Uint8
Writeln(Format('
NumberOfPorts %d',[VarToInt(FWbemObject.NumberOfPorts)]));
// Uint8
Writeln(Format('
PNPDeviceID %s',[VarToStr(FWbemObject.PNPDeviceID)]));
// String
// Writeln(Format('PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities)]));// Array of Uint16
for j:= low(VarToInt(FWbemObject.PowerManagementCapabilities))
to high(VarToInt(FWbemObject.PowerManagementCapabilities))
do
Writeln(Format('
PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities[j])]));
Writeln(Format('
PowerManagementSupported %s',[VarToStr(FWbemObject.PowerManagementSupported)]));
// Boolean
Writeln(Format('
ProtocolCode %d',[VarToInt(FWbemObject.ProtocolCode)]));
// Uint8
Writeln(Format('
Status %s',[VarToStr(FWbemObject.Status)]));
// String
Writeln(Format('
StatusInfo %d',[VarToInt(FWbemObject.StatusInfo)]));
// Uint16
Writeln(Format('
SubclassCode %d',[VarToInt(FWbemObject.SubclassCode)]));
// Uint8
Writeln(Format('
SystemCreationClassName %s',[VarToStr(FWbemObject.SystemCreationClassName)]));
// String
Writeln(Format('
SystemName %s',[VarToStr(FWbemObject.SystemName)]));
// String
Writeln(Format('
USBVersion %d',[VarToInt(FWbemObject.USBVersion)]));
// Uint16
Writeln(StringOfChar('
-',80));
FWbemObject:=Unassigned;
end;
end;
// Die Klasse "Win32_NetworkAdapter" stellt einen Netzwerkadapter in einem Win32-
// System dar.
procedure GetWin32_NetworkAdapterInfo;
const
WbemUser ='
';
WbemPassword ='
';
WbemComputer ='
localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator : OLEVariant;
FWMIService : OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
j : Integer;
begin;
FSWbemLocator := CreateOleObject('
WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, '
root\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet:= FWMIService.ExecQuery('
SELECT * FROM Win32_NetworkAdapter','
WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0
do
begin
Writeln(Format('
AdapterType %s',[VarToStr(FWbemObject.AdapterType)]));
// String
Writeln(Format('
AdapterTypeId %d',[VarToInt(FWbemObject.AdapterTypeId)]));
// Uint16
Writeln(Format('
AutoSense %s',[VarToStr(FWbemObject.AutoSense)]));
// Boolean
Writeln(Format('
Availability %d',[VarToInt(FWbemObject.Availability)]));
// Uint16
Writeln(Format('
Caption %s',[VarToStr(FWbemObject.Caption)]));
// String
Writeln(Format('
ConfigManagerErrorCode %d',[VarToInt(FWbemObject.ConfigManagerErrorCode)]));
// Uint32
Writeln(Format('
ConfigManagerUserConfig %s',[VarToStr(FWbemObject.ConfigManagerUserConfig)]));
// Boolean
Writeln(Format('
CreationClassName %s',[VarToStr(FWbemObject.CreationClassName)]));
// String
Writeln(Format('
Description %s',[VarToStr(FWbemObject.Description)]));
// String
Writeln(Format('
DeviceID %s',[VarToStr(FWbemObject.DeviceID)]));
// String
Writeln(Format('
ErrorCleared %s',[VarToStr(FWbemObject.ErrorCleared)]));
// Boolean
Writeln(Format('
ErrorDescription %s',[VarToStr(FWbemObject.ErrorDescription)]));
// String
Writeln(Format('
GUID %s',[VarToStr(FWbemObject.GUID)]));
// String
Writeln(Format('
Index %d',[VarToInt(FWbemObject.
Index)]));
// Uint32
Writeln(Format('
InstallDate %s',[VarToStr(FWbemObject.InstallDate)]));
// Datetime
Writeln(Format('
Installed %s',[VarToStr(FWbemObject.Installed)]));
// Boolean
Writeln(Format('
InterfaceIndex %d',[VarToInt(FWbemObject.InterfaceIndex)]));
// Uint32
Writeln(Format('
LastErrorCode %d',[VarToInt(FWbemObject.LastErrorCode)]));
// Uint32
Writeln(Format('
MACAddress %s',[VarToStr(FWbemObject.MACAddress)]));
// String
Writeln(Format('
Manufacturer %s',[VarToStr(FWbemObject.Manufacturer)]));
// String
Writeln(Format('
MaxNumberControlled %d',[VarToInt(FWbemObject.MaxNumberControlled)]));
// Uint32
Writeln(Format('
MaxSpeed %d',[VarToInt(FWbemObject.MaxSpeed)]));
// Uint64
Writeln(Format('
Name %s',[VarToStr(FWbemObject.
Name)]));
// String
Writeln(Format('
NetConnectionID %s',[VarToStr(FWbemObject.NetConnectionID)]));
// String
Writeln(Format('
NetConnectionStatus %d',[VarToInt(FWbemObject.NetConnectionStatus)]));
// Uint16
Writeln(Format('
NetEnabled %s',[VarToStr(FWbemObject.NetEnabled)]));
// Boolean
// Writeln(Format('NetworkAddresses %s',[VarToStr(FWbemObject.NetworkAddresses)]));// Array of String
// Writeln(Format('PermanentAddress %s',[VarToStr(FWbemObject.PermanentAddress)]));// String
Writeln(Format('
PhysicalAdapter %s',[VarToStr(FWbemObject.PhysicalAdapter)]));
// Boolean
Writeln(Format('
PNPDeviceID %s',[VarToStr(FWbemObject.PNPDeviceID)]));
// String
// Writeln(Format('PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities)]));// Array of Uint16
for j:= low(VarToInt(FWbemObject.PowerManagementCapabilities))
to high(VarToInt(FWbemObject.PowerManagementCapabilities))
do
Writeln(Format('
PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities[j])]));
Writeln(Format('
PowerManagementSupported %s',[VarToStr(FWbemObject.PowerManagementSupported)]));
// Boolean
Writeln(Format('
ProductName %s',[VarToStr(FWbemObject.ProductName)]));
// String
Writeln(Format('
ServiceName %s',[VarToStr(FWbemObject.ServiceName)]));
// String
Writeln(Format('
Speed %d',[VarToInt(FWbemObject.Speed)]));
// Uint64
Writeln(Format('
Status %s',[VarToStr(FWbemObject.Status)]));
// String
Writeln(Format('
StatusInfo %d',[VarToInt(FWbemObject.StatusInfo)]));
// Uint16
Writeln(Format('
SystemCreationClassName %s',[VarToStr(FWbemObject.SystemCreationClassName)]));
// String
Writeln(Format('
SystemName %s',[VarToStr(FWbemObject.SystemName)]));
// String
Writeln(Format('
TimeOfLastReset %s',[VarToStr(FWbemObject.TimeOfLastReset)]));
// Datetime
Writeln(StringOfChar('
-',80));
FWbemObject:=Unassigned;
end;
end;
begin
try
CoInitialize(
nil);
try
// GetWin32_USBHubInfo;
GetWin32_NetworkAdapterInfo;
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;
Writeln('
Press Enter to exit');
Readln;
end.