⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 用Delphi捕获U盘插入或者拔出事件。
💻 PAS
字号:
unit   Unit1;   
    
  interface   
    
  uses   
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,   
      Dialogs,   AppEvnts,   ExtCtrls,   StdCtrls;   
    
  type   
      TForm1   =   class(TForm)   
          Label1:   TLabel;   
      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;   
  begin   
      Case   Msg.WParam   of   
      32768:   
          begin   
              myMsg   :='U盘插入';   
              Label1.Caption:=myMsg   
          end;   
      32772:   
          begin   
              myMsg   :='U盘拔出';   
              Label1.Caption:=myMsg;   
          end;   
      end;   
  end;   
    
  end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -