Inno Setup中的异步WMI查询

时间:2016-06-01 13:52:45

标签: asynchronous inno-setup wmi-query

我正在尝试在我的Inno Setup项目中实现异步WMI查询。但我正在努力解决事件定义。我在第

行收到Type mismatch错误

objSink.OnCompleted := @WMI_OnCompleted;

我假设我的事件定义是错误的。如何找到事件的正确对象类型?

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;

1 个答案:

答案 0 :(得分:1)

根据Inno Setup Newsgroup,这实际上似乎是不可能的。至少用我的方法:

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