• Dy1 (25.07.09 00:29) [0]
    полтора года назад поднимался вопрос. Помогите плз, я до сих пор не понимаю 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);{здесь у меня ошибка Exception with message ''}
    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;
    { except
    on exception do
     result := '';
    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.

  • Dy1 (28.07.09 12:09) [1]
    помогите пожалуйста
Есть новые Нет новых   [134465   +2][b:0][p:0.001]