Solved

Opening/closing CD-Drive

Posted on 1997-03-16
6
172 Views
Last Modified: 2010-04-04
I know how to open and close a CD-drive, but I like to be able to choose between two available drives. How do I choose which device to open with MciSendCommand??

CD-Drives: F and G

I need to know how to open G
0
Comment
Question by:OAM
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:sperling
ID: 1334918
 FillChar(OpenParms, SizeOf(OpenParms), 0);
  OpenParms.lpstrDeviceType :=
    POINTER(MCI_DEVTYPE_CD_AUDIO + 1 shl 16);

// High word is device number      ^

  Error := mciSendCommand(MCI_DEVTYPE_CD_AUDIO,
    MCI_OPEN,
    MCI_OPEN_TYPE or MCI_WAIT
   
    or MCI_OPEN_TYPE_ID
// Indicate that we specify an device number  

    or MCI_OPEN_SHAREABLE,
    INTEGER(@OpenParms));


This code should work according to my docs.
I cannot test it, as I ain't got any machines with to CD's...

Erik.
0
 

Author Comment

by:OAM
ID: 1334919
Edited text of question
0
 

Author Comment

by:OAM
ID: 1334920
Didn't work the way it was suppose to.

Not enough comments (It is a 100 point question)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:sperling
ID: 1334921
What OpenParms did you use, and what errors did you get?

Regards,

Erik.
0
 

Author Comment

by:OAM
ID: 1334922
Well I't didn't work.

OpenParms.lpstrDeviceType :=                                          POINTER(MCI_DEVTYPE_CD_AUDIO + 1 shl 16);

It is not too clear to me what this is suppose to do.



0
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
ID: 1334923
procedure TForm1.Button1Click(Sender: TObject);
var
  Error      : INTEGER;
  a          : ARRAY [0..199] OF CHAR;
begin
  Error := mciSendString('open cdaudio1', a, SizeOf(a), 0);
  mciGetErrorString(Error, a, SizeOf(a));
  Label1.Caption := StrPas(a);
end;

This should work.

> POINTER(MCI_DEVTYPE_CD_AUDIO + 1 shl 16)

According to docs, the high-order word of this pointer indicates the ordinal number of the device. "X shl 16" sets the high order word to X... But then, it didn't work... Kind of hard to find this out, as I haven't got two of any MCI devices on any of my pcs...


Regards,

Erik.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 93
Delphi : could not find program, '...exe' 2 148
Reconfigure Delphi Install? 2 46
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 57
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now