获取系统消息---监控usb接口
本帖最后由 nxbigdaddy 于 2009-11-2 17:05 编辑我想通过获取系统消息来监控u盘的插入,不知该如何处理,求救啊…… 没人理我吗?各位大虾 $strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colEvents = $objWMIService.ExecNotificationQuery _
("Select * From __InstanceOperationEvent Within 5 Where " _
& "TargetInstance isa 'Win32_LogicalDisk'")
While 1
$objEvent = $colEvents.NextEvent
If $objEvent.TargetInstance.DriveType = 2 Then
Select
Case $objEvent.Path_.Class()="__InstanceCreationEvent"
MsgBox(262144, "哎呀", "可移动磁盘" & $objEvent.TargetInstance.DeviceId & "已经插进来了!",3)
;Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR)
Case $objEvent.Path_.Class()="__InstanceDeletionEvent"
;Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR)
MsgBox(262144, "哎呀", "可移动磁盘" & $objEvent.TargetInstance.DeviceId & "被拔出去了~",3)
EndSelect
EndIf
WEnd 谢谢楼上了…… 高级代码....没看懂,加个注释吧... 留名,回头用上的时候再来感谢3mile 是啊 ,谢谢谢谢 这一段很经典,要支持一下。 留名,回头用上的时候再来感谢3mile 其实,有非主动捕获消息的方法吗?意思是,不用放循环,或者adlib里面的?? http://www.autoitx.com/forum.php?mod=viewthread&tid=17747 这些代码运行不了啊 做个标记!!!!!来日再取 鼎力支持啊咯 好东西啊,,就是看不懂
页:
[1]
2