一个检测U盘插入与拔出的函数
时间 2020-01-27
标签
一个
检测
u盘
插入
拔出
函数
消息方法
申明
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
实现
procedure TForm1.WMDeviceChange(var Msg: TMessage); var myMsg : String; begin Case Msg.WParam of 32768: begin myMsg :='U盘插入'; Label1.Caption:=myMsg end; 32772: begin myMsg :='U盘拔出'; Label1.Caption:=myMsg; end; end; end;