用MCI命令,详见mmSystem单元
判断光驱状态并使其弹出关闭:
   program cdinout; 
    uses mmSystem; 
     
    var 
    MCIO : TMCI_Open_Parms; 
    MCIS : TMCI_Status_Parms; 
     
    begin 
     
    MCIO.lpstrDeviceType := PChar(MCI_DEVTYPE_CD_AUDIO); 
    if mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE or MCI_OPEN_TYPE_ID or 
     MCI_OPEN_SHAREABLE, LongInt(@MCIO) )= 0 then 
     begin 
     MCIS.dwItem := MCI_STATUS_READY; 
     mciSendCommand(MCIO.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM 
     or MCI_WAIT, LongInt(@MCIS)); 
     if MCIS.dwReturn<> 0 then 
     mciSendCommand(MCIO.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0) 
     else 
     mciSendCommand(MCIO.wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0); 
     mciSendCommand(MCIO.wDeviceID, MCI_CLOSE, MCI_WAIT, 0); 
     end; 
    end. 

解决方案 »

  1.   

    没有那么麻烦,试一下这个:
    procedure TfrmMain.Open_cdClick(Sender: TObject);
    begin
        mciexecute('open cdaudio alias cd');
        mciexecute('set cd door open');
        mciexecute('close cd');
    end;procedure TfrmMain.close_cdClick(Sender: TObject);
    begin
        mciexecute('open cdaudio alias cd');
        mciexecute('set cd door closed');
        mciexecute('close cd');
    end;
      

  2.   

    mciexectute是不是再9x下没有这个命令
      

  3.   

    //open;mciSendString('Set cdaudio door open wait', nil, 0, handle); //close 
    mciSendString('Set cdaudio door closed wait', nil, 0, handle)