Reputation: 605
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 mismatch
error 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;
Upvotes: 3
Views: 506
Reputation: 605
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
Upvotes: 1