//自动检测U盘
import win.ui;
/*DSG{{*/
var winform = win.form( bottom=275;parent=...;right=481;text="自动检测插入U盘" )
winform.add( 
static={ bottom=263;right=470;left=15;top=15;transparent=1;text="请插入U盘";z=1;edge=1;cls="static" }
)
/*}}*/

import win.util.deviceNotification;
var deviceNotification = win.util.deviceNotification(winform)

deviceNotification.onDeviceArrival = function(drive,driveType,deviceName,deviceType,flags){
	if( driveType == 0x2/*_DRIVE_REMOVABLE*/ ){
		winform.static.text += ("插入移动磁盘" + " " + drive + " " + deviceName + '\r\n' )
	}
	elseif( driveType == 0x5/*_DRIVE_CDROM*/ ){
		winform.static.text += ("插入光盘" + " " + drive + " " + deviceName + '\r\n' )
	} 
}
deviceNotification.onDeviceRemoveComplete = function(drive,removable,driveType,deviceType,flags){
		winform.static.text += ("移除设盘" + " " + drive + '\r\n' )
}
 
winform.show() 
win.loopMessage();
