Solved

Opening/closing CD-Drive

Posted on 1997-03-16
6
175 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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