消息方法
申明
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;