The following is an example of using WMI with Delphi.
More examples can be found at:
http://www.planetmps.com/
var
locator : TSWbemLocator;
Services : ISWbemServices;
ObjSet : ISWbemObjectSet;
ob : ISWbemObject;
Obj : ISWbemObject;
PropSet : ISWbemPropertySet;
Prop : ISWbemProperty;
propEnum : IEnumVariant;
objEnum : IEnumVariant;
tempObj : OleVariant;
tempObj1 : OleVariant;
Count : Cardinal;
Value : Cardinal;
sValue : String;
sValue : String;
begin
locator := TSWbemlocator.Create(self);
Services := locator.ConnectServer('', 'root\CIMV2\ms_409', '', '', '', '', 0, nil);
ob := Services.Get('Win32_BIOS');
ObjSet := ob.Instances_;
Enum := IUnknown(ObjSet._NewEnum ) as IEnumVariant;
while (Enum.Next(1, tempObj, Value) = S_OK) do
begin
Obj := IUnknown(tempObj) as SWBemObject;
PropSet := lSObject.Properties_;
propEnum := IUnknown(PropSet._NewEnum) as IEnumVariant;
while (propEnum.Next(1, tempObj1, Count) = S_OK) do
begin
Prop := IUnknown(tempObj1) as SWBemProperty;
if(y == 2) then do
begin
objexcel.Cells(1, x).Value := prop.Name;
}
objexcel.Cells(y, x).Value := GetValue(prop.Name, mo);
x=x+1;
}
x=1;
y=y+1;
end;
break;
end;
No comments:
Post a Comment