Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Async WMI Query in Inno Setup

I'm trying to implement asynchronous WMI queries in my Inno Setup project. But I'm struggling with the event definitions. I'm getting a Type mismatcherror on the line

objSink.OnCompleted := @WMI_OnCompleted;

I am assuming that my event definition is wrong. How can I find the right object types for the event?

procedure QueryWMIAsync(Qry: string; var objSink: Variant);
var
  WbemLocator, WbemServices, WbemObjects: Variant;
begin
  log('WMI AsyncQuery: '+Qry);
  try
    WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
    objSink.OnCompleted := @WMI_OnCompleted; //<----- Error: Type mismatch
    objSink.OnObjectReady := @WMI_OnObjectReady;    

    WbemServices := WbemLocator.ConnectServer('localhost', 'root\CIMV2');
    WbemServices.ExecQueryAsync(objSink, Qry);    
  except
    MsgBox('ERROR on WMI Query <'+Qry+'>: '+GetExceptionMessage,mbError,MB_OK);
  end;
end;

procedure WMI_OnCompleted(hResult: HRESULT; error: Variant; asyncContext: Variant);
begin

end;
like image 905
Marco Rebsamen Avatar asked Mar 03 '26 14:03

Marco Rebsamen


1 Answers

According to the Inno Setup Newsgroup this actually seems to be impossible. At least with my approach:

http://news.jrsoftware.org/read/article.php?id=30095&group=jrsoftware.innosetup.code#30095

like image 89
Marco Rebsamen Avatar answered Mar 06 '26 21:03

Marco Rebsamen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!