Delphi WMI[2] 响应网线断开
作者:互联网
Delphi WMI[2] 响应网线断开
uses WbemScripting_TLB,ActiveX,ComObj; procedure OnDisconnect(Sender: TObject; var objWbemObject: OleVariant; var objWbemAsyncContext: OleVariant); procedure TForm1.OnDisconnect(Sender: TObject; var objWbemObject: OleVariant; var objWbemAsyncContext: OleVariant); begin ShowMessage(' 网络中断啦! TaoRoy'); end; procedure TForm1.BitBtn11Click(Sender: TObject); var Locator: TSWbemLocator; Services: ISWbemServices; SinkClassesC: TSWbemSink; SinkClassesD: TSWbemSink; begin Locator := TSWbemLocator.Create(self); Services := Locator.ConnectServer('', '\root\wmi', '', '', '', '', 0, nil); SinkClassesD := TSWbemSink.Create(self); SinkClassesD.OnObjectReady:=OnDisconnect; // Event Notifier 事件通知程序 // Connect Async Event 连接异步事件 Services.ExecNotificationQueryAsync( SinkClassesD.DefaultInterface, 'Select * from MSNdis_StatusMediaDisconnect', 'WQL', 0, nil, nil); end;
创建时间:2021.07.28 更新时间:
标签:Sender,nil,Delphi,OleVariant,网线,SinkClassesD,WMI,var,TSWbemSink 来源: https://www.cnblogs.com/guorongtao/p/15071037.html