Link to home
Start Free TrialLog in
Avatar of biniyi
biniyi

asked on

Need Help:delphi access WMI --how to modify the property

I'm use delphi 7.0 + WbemScripting_TLB.pas access WMI.
      I can read the property's value, but unknown howto modify proerty's
value.
      how to use SWBemObject.Put_ method??
      need your help, thank's.

     attach my code.
----------------------------------------------------------------------------
//......
      Locator := CoSWbemLocator.Create;
//.....
      Services :=  Locator.ConnectServer('', 'root\......
//.....
      wmiObject := IUnknown(TempObj) as SWBemObject;
      propSet   := wmiObject.Properties_;
      propEnum := (propSet._NewEnum) as IEnumVariant;
      Set_v := 'XX'+'...';
      //get property list
      while (propEnum.Next(1, TempObj, Value) = S_OK) do begin
        wmiProp  := IUnknown(TempObj) as SWBemProperty;

          case wmiProp.CIMType of
          wbemCimtypeString:
          begin
            //select value into Temp_S, success.
            Temp_S := Temp_S+wmiProp.Name+':'+wmiProp.Get_Value()+#13#10;
            wmiProp.Set_Value(Set_v);

//=============
            wmiObject.Put_(0,null); //Error! ---need help how to use SWBemObject.Put_??

//=============
          end;
        end
//......
----------------------------------------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of Melih SARICA
Melih SARICA
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial