找回密码
 加入
搜索
查看: 4406|回复: 15

获取系统消息---监控usb接口

 火.. [复制链接]
发表于 2009-10-30 08:50:13 | 显示全部楼层 |阅读模式
本帖最后由 nxbigdaddy 于 2009-11-2 17:05 编辑

我想通过获取系统消息来监控u盘的插入,不知该如何处理,求救啊……
 楼主| 发表于 2009-10-30 16:41:05 | 显示全部楼层
没人理我吗?各位大虾
发表于 2009-10-30 18:59:58 | 显示全部楼层
$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
 楼主| 发表于 2009-11-2 17:05:31 | 显示全部楼层
谢谢楼上了……
发表于 2009-11-14 02:21:24 | 显示全部楼层
高级代码....没看懂,加个注释吧...
发表于 2009-11-16 13:47:05 | 显示全部楼层
留名,回头用上的时候再来感谢3mile
 楼主| 发表于 2009-11-17 14:33:40 | 显示全部楼层
是啊 ,谢谢谢谢
发表于 2010-6-18 19:51:48 | 显示全部楼层
这一段很经典,要支持一下。
发表于 2010-9-8 08:11:01 | 显示全部楼层
留名,回头用上的时候再来感谢3mile
发表于 2010-11-17 08:49:20 | 显示全部楼层
其实,有非主动捕获消息的方法吗?意思是,不用放循环,或者adlib里面的??
 楼主| 发表于 2010-11-17 10:01:55 | 显示全部楼层
发表于 2010-11-18 20:58:02 | 显示全部楼层
这些代码运行不了啊
发表于 2011-9-19 21:17:09 | 显示全部楼层
做个标记!!!!!来日再取
发表于 2012-3-16 10:59:40 | 显示全部楼层
鼎力支持啊咯
发表于 2012-3-19 11:04:20 | 显示全部楼层
好东西啊,,就是看不懂
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-30 05:40 , Processed in 0.089326 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表