[WMI实例]在网络连接断开时通知用户

strComputer := "."

objWMIService := ComObjGet("winmgmts:\\" strComputer "\root\wmi")
colMonitoredEvents := objWMIService.ExecNotificationQuery("Select * from MSNdis_StatusMediaDisconnect") 

Loop
{
        strLatestEvent := colMonitoredEvents.NextEvent 
    MsgBox, % "有一个网络连接断开了: " strLatestEvent.InstanceName
}
return
strComputer := "."

objWMIService := ComObjGet("winmgmts:\\" strComputer "\root\wmi")
colMonitoredEvents := objWMIService.ExecNotificationQuery("Select * from MSNdis_StatusMediaConnect") 

Loop
{
        strLatestEvent := colMonitoredEvents.NextEvent 
    MsgBox, % "有一个网络连接建立了: " strLatestEvent.InstanceName
}
return

 

posted @ 2013-09-27 22:46  cnsealine  阅读(562)  评论(0编辑  收藏  举报