• U盘插入拔出提示


    Unit Unit1;
    
    Interface
    
    Uses
    
      Windows, Messages, SysUtils, Variants, classes, Graphics, Controls, Forms,
    
      Dialogs, AppEvnts, ExtCtrls, StdCtrls, ShellAPI;
    
    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;
    
      i: char;
    
    Begin
    
      Case Msg.WParam Of
    
        32768: Begin
    
            ShowMessage('U盘插入');
    
            For i := 'D' To 'Z' Do
    
              If GetDriveType(PChar(i + ':"')) = DRIVE_REMOVABLE Then Begin
    
                ShellExecute(Handle, 'open', 'Explorer.exe', PChar(i + ':"'), Nil, SW_SHOWNORMAL);
    
              End;
    
          End;
    
        32772: Begin
    
                ShowMessage('U盘退出')
    
        End;
    
      End;
    
    End;
    
    End.
  • 相关阅读:
    编译预处理命令define
    共享数据的包含const
    友元类,友元函数
    静态成员static
    this 指针
    构造函数与析构函数
    c++类的基础
    void指针和const指针
    c++基础
    组播的实现
  • 原文地址:https://www.cnblogs.com/karkash/p/7933757.html
Copyright © 2020-2023  润新知