Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Eject/Close CD-rom drive in one command

Posted on 2001-09-08
8
Medium Priority
?
1,538 Views
Last Modified: 2007-12-19
How can I eject and close cd-rom drive by one button , so if it is closed I eject, if it is opened I close it .
I know that for close :
mcisendmessage('set cdaudio door closed wait',nil,0,handle);
and for Eject is : mcisendmessage('set cdaudio door closed wait',nil,0,handle);
I would know how combine the two commands in one procedure for ejecting or closing cd-rom drive .
0
Comment
Question by:nabildatone
8 Comments
 
LVL 1

Expert Comment

by:Dennis9
ID: 6467198
listening...
0
 
LVL 1

Expert Comment

by:Dennis9
ID: 6467239
listening...
0
 
LVL 2

Expert Comment

by:DidierD
ID: 6467487
Hi,

I think zifnab is the expert here who knows a lot about it, but i haven't seen him here for a while. The code below comes from him.
 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

const
  DBT_DEVICEARRIVAL = 32772;
  DBT_DEVICEREMOVECOMPLETE = 32768;

type
  TForm1 = class(TForm)
    procedure WndProc(var Msg: TMessage); override;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WndProc(var Msg: TMessage);
begin
if Msg.Msg = WM_DEVICECHANGE then begin
 case Msg.wParam of
  DBT_DEVICEARRIVAL : begin
    showmessage('CD DOOR OPEN');
   end;
  DBT_DEVICEREMOVECOMPLETE : begin
    showmessage('CD DOOR CLOSE');
   end;
 end;
end
  else inherited WndProc(MSg);
end;

end.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Accepted Solution

by:
DrDelphi earned 200 total points
ID: 6467746
procedure CDOpenClose;
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;


Good luck!!

0
 

Expert Comment

by:DelFreak
ID: 6467965
Listening...
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6468648
listening...for moment
0
 
LVL 17

Expert Comment

by:geobul
ID: 9295952
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

accept DrDelphi's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question