# win.util.deviceNotification 库模块帮助文档

## win.util 成员列表 <a id="win.util" href="#win.util">&#x23;</a>

### win.util.deviceNotification <a id="win.util.deviceNotification" href="#win.util.deviceNotification">&#x23;</a>
设备检测

### win.util.deviceNotification() <a id="win.util.deviceNotification" href="#win.util.deviceNotification">&#x23;</a>
[返回对象:winDeviceNotificationObject](#winDeviceNotificationObject)

### win.util.deviceNotification(输入winform对象) <a id="win.util.deviceNotification" href="#win.util.deviceNotification">&#x23;</a>
创建一个设备通知窗口  
在添加或移除设备时可响应通知消息  
可选使用参数@2指定GUID

## winDeviceNotificationObject 成员列表 <a id="winDeviceNotificationObject" href="#winDeviceNotificationObject">&#x23;</a>

## winDeviceNotificationObject 事件列表 <a id="winDeviceNotificationObjectEvent" href="#winDeviceNotificationObjectEvent">&#x23;</a>

### winDeviceNotificationObject.onDeviceArrival <a id="winDeviceNotificationObject.onDeviceArrival" href="#winDeviceNotificationObject.onDeviceArrival">&#x23;</a>

```aardio
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 <a id="winDeviceNotificationObject.onDeviceQueryRemove" href="#winDeviceNotificationObject.onDeviceQueryRemove">&#x23;</a>

```aardio
winDeviceNotificationObject.onDeviceQueryRemove = function(devType,devData,pDevData){

}
```

### winDeviceNotificationObject.onDeviceQueryRemoveFailed <a id="winDeviceNotificationObject.onDeviceQueryRemoveFailed" href="#winDeviceNotificationObject.onDeviceQueryRemoveFailed">&#x23;</a>

```aardio
winDeviceNotificationObject.onDeviceQueryRemoveFailed = function(devType,devData,pDevData){

}
```

### winDeviceNotificationObject.onDeviceRemoveComplete <a id="winDeviceNotificationObject.onDeviceRemoveComplete" href="#winDeviceNotificationObject.onDeviceRemoveComplete">&#x23;</a>

```aardio
winDeviceNotificationObject.onDeviceRemoveComplete = function(devType,devData,pDevData){
	if( devType == 2/*_DBT_DEVTYP_VOLUME*/ ){
		if( devData.isUsbDevice ){
			io.print("移除U盘",devData.drives[1])
		}
	}
}
```

### winDeviceNotificationObject.onDeviceRemovePending <a id="winDeviceNotificationObject.onDeviceRemovePending" href="#winDeviceNotificationObject.onDeviceRemovePending">&#x23;</a>

```aardio
winDeviceNotificationObject.onDeviceRemovePending = function(devType,devData,pDevData){

}
```

### winDeviceNotificationObject.onDeviceTypeSpecific <a id="winDeviceNotificationObject.onDeviceTypeSpecific" href="#winDeviceNotificationObject.onDeviceTypeSpecific">&#x23;</a>

```aardio
winDeviceNotificationObject.onDeviceTypeSpecific = function(devType,devData,pDevData){

}
```

### winDeviceNotificationObject.onVolumeArrival <a id="winDeviceNotificationObject.onVolumeArrival" href="#winDeviceNotificationObject.onVolumeArrival">&#x23;</a>

```aardio
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 <a id="winDeviceNotificationObject.onVolumeRemoveComplete" href="#winDeviceNotificationObject.onVolumeRemoveComplete">&#x23;</a>

```aardio
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  
