полтора года назад поднимался вопрос. Помогите плз, я до сих пор не понимаю ActiveX
program test;
uses
KOL, WbemScripting_TLBKOL, ActiveX, Variants;
function GetWMIstring2 (wmiHost, wmiClass, wmiProperty : string):string;
var
Locator: ISWbemLocator;
Services: ISWbemServices;
SObject: ISWbemObject;
ObjSet: ISWbemObjectSet;
SProp: ISWbemProperty;
Enum: IEnumVariant;
Value: Cardinal;
TempObj: OleVariant;
SN: string;
begin
Locator := CoSWbemLocator.Create;
Services := Locator.ConnectServer(wmiHost, 'root\wmi', '', '', '','', 0, nil);
ObjSet := Services.ExecQuery('SELECT * FROM '+wmiClass, 'WQL',
wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
Enum := (ObjSet._NewEnum) as IEnumVariant;
while (Enum.Next(1, TempObj, Value) = S_OK) do
begin
SObject := IUnknown(tempObj) as ISWBemObject;
SProp := SObject.Properties_.Item(wmiProperty, 0);
if VarIsNull(SProp.Get_Value) then
result := ''
else
begin
SN := SProp.Get_Value;
result := SN;
end;
end;
end;
procedure ButtonClick(Dummy: Pointer; Sender: PControl);
begin
MsgOK(getWMIstring2('','MSAcpi_ThermalZoneTemperature','CurrentTemperature') );
end;
begin
Applet := NewForm(nil,'Test').SetSize(200,200);
with NewButton(Applet,'Temp')^ do
begin
CenterOnParent;
OnClick := TOnEvent(MakeMethod(nil,@ButtonClick));
end;
OleInit;
Run(Applet);
OleUnInit;
end.