zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    使用GitLab搭建Git仓库
    SpringBoot web开发
    springboot配置
    springboot自动配置原理
    springboot修改端口号
    springboot创建方式
    junit运行多个测试的方法
    junit常用注解
    junit断言
    sublime将.m文件关联MATLAB类型高亮
  • 原文地址:https://www.cnblogs.com/lzhdim/p/1343853.html
Copyright © 2011-2022 走看看