弹出:interface
    TForm1 = class(TForm)
       ...
    public
       procedure WMDeviceChange(var Msg: TMsg); message WM_DEVICECHANGE;implementationprocedure TForm1.WMDeviceChange(var Msg: TMsg);
begin
    if Msg.wParam = DBT_DEVICEREMOVEPENDING then
        // user has started to eject CD
        // Tell Windows it's OK.
        Msg.Result := True;
end;
//////////////////////////////////////////////////////
You can write a message handler for the WM_DEVICECHANGE message. If
the CD tray is ejected, the value of wParam of the message will be
DBT_DEVICEREMOVECOMPLETE.  Take a look at WM_DEVICECHANGE in the
Win32.hlp

解决方案 »

  1.   

    //打开光驱 
    mciSendString('Set cdaudio door open wait', nil, 0, handle); 
    //关闭光驱 
    mciSendString('Set cdaudio door closed wait', nil, 0, handle) 关于第二个问题用
    BOOL RegisterHotKey(
        HWND hWnd, // window to receive hot-key notification
        int id, // identifier of hot key ID 例如:$168
        UINT fsModifiers, // key-modifier flags 例如:MOD_CONTROL{Ctrl键}
        UINT vk // virtual-key code 例如:VK_RETURN{回车键}
      );用UnRegisterHotKey(Handle,$168); 在程序结束时取消自定义的热键
      

  2.   

    对,就是用mcisendstring函数,你要是用mcisendcommand的话,就会得到更多的功能。
      

  3.   

    对于托盘的话,你可以用现成的控件,用一个popupmenu来控制托盘里的行为。
      

  4.   

    哦,错了,对于按键的情况,你也可以用热键,也可以用一个钩子(做到dll中)来监控。
      

  5.   

    在接口部分还要声明什么?“mcisendstring” 未说明标识符???