CD in/out(光驱硬打开/关闭事件的检测 - 自解)

来源:互联网 发布:深度优先搜索算法 编辑:程序博客网 时间:2024/05/20 06:30
Here's how to be notified when CD drawer is opened or closed:

~~~~~~~~~~~~~~~~~~~~~~~~~
{Put this line into private section
of your form's declaration}
procedure WMDeviceChange(var Msg: TMessage) ;
           message WM_DEVICECHANGE;

{the implementation part:}
  procedure TForm1.WMDeviceChange
            (var Msg: TMessage) ;
  const
    CD_IN = $8000;
    CD_OUT = $8004;
  var
    Msg : String;
  begin
    inherited;
    case Msg.wParam of
      CD_IN : Msg := 'CD in';
      CD_OUT : Msg := 'CD out';
    end;
    ShowMessage(Msg) ;
  end;
~~~~~~~~~~~~~~~~~~~~~~~~~
 

原创粉丝点击