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

x
?
Solved

Opening/closing CD-Drive

Posted on 1997-03-16
6
Medium Priority
?
180 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview
Suggested Courses

916 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