设备检测
返回对象:winDeviceNotificationObject
创建一个设备通知窗口
在添加或移除设备时可响应通知消息
可选使用参数@2指定GUID
winDeviceNotificationObject.onDeviceArrival = function(devType,devData,pDevData){
if( devType == 2/*_DBT_DEVTYP_VOLUME*/ ){
if( devData.isMedia ){
io.print("插入光盘",devData.drives[1] )
}
elseif( devData.isNet ){
io.print("添加网络卷",devData.drives[1])
}
else {
io.print("添加磁盘",devData.drives[1])
}
}
}
winDeviceNotificationObject.onDeviceQueryRemove = function(devType,devData,pDevData){
}
winDeviceNotificationObject.onDeviceQueryRemoveFailed = function(devType,devData,pDevData){
}
winDeviceNotificationObject.onDeviceRemoveComplete = function(devType,devData,pDevData){
if( devType == 2/*_DBT_DEVTYP_VOLUME*/ ){
if( devData.isUsbDevice ){
io.print("移除U盘",devData.drives[1])
}
}
}
winDeviceNotificationObject.onDeviceRemovePending = function(devType,devData,pDevData){
}
winDeviceNotificationObject.onDeviceTypeSpecific = function(devType,devData,pDevData){
}
winDeviceNotificationObject.onVolumeArrival = function(devData,pDevData){
if( devData.isMedia ){
io.print("插入光盘",devData.drives[1] )
}
elseif( devData.isNet ){
io.print("添加网络卷",devData.drives[1])
}
elseif(sys.storage.isUsbDevice(devData.drives[1])){
io.print("插入U盘",devData.drives[1] )
}
}
winDeviceNotificationObject.onVolumeRemoveComplete = function(devData,pDevData){
io.print("移除:",devData.drives[1])
}
_BROADCAST_QUERY_DENY=0x424D5144
_DBT_DEVICEARRIVAL=0x8000
_DBT_DEVICEQUERYREMOVE=0x8001
_DBT_DEVICEQUERYREMOVEFAILED=0x8002
_DBT_DEVICEREMOVECOMPLETE=0x8004
_DBT_DEVICEREMOVEPENDING=0x8003
_DBT_DEVICETYPESPECIFIC=0x8005
_DBT_DEVTYP_DEVICEINTERFACE=5
_DBT_DEVTYP_DEVINST=7
_DBT_DEVTYP_DEVNODE=1
_DBT_DEVTYP_HANDLE=6
_DBT_DEVTYP_NET=4
_DBT_DEVTYP_OEM=0
_DBT_DEVTYP_PORT=3
_DBT_DEVTYP_VOLUME=2
_WM_DEVICECHANGE=0x0219