U盘插入拔出检测

来源:互联网 发布:三剑客软件 编辑:程序博客网 时间:2024/05/01 22:05
unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    Button1: TButton;  private    { Private declarations }    procedure WMDeviceChange(var Msg:TMessage);message WM_DEVICECHANGE;  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WMDeviceChange(var Msg:TMessage);var myMsg:String;beginshowmessage(IntToStr(msg.WParam)); Case Msg.WParam of  32768:    begin     myMsg:='U盘插入';     showmessage(myMsg);    end;  32772:    begin     myMsg:='U盘拔出';     showmessage(myMsg);    end;  end;end;end.

原创粉丝点击