[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

what windows sdk function do I call to eject the cd?

Posted on 2006-05-18
14
Medium Priority
?
285 Views
Last Modified: 2010-04-15
what windows sdk method do I call to eject the cd? (also, what sdk method will cause the cd door to be closed?)

please give me an example of calling the code also - thanks
0
Comment
Question by:Omnipower
10 Comments
 

Author Comment

by:Omnipower
ID: 16708844
C on Windows XP
0
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
ID: 16709000
You have to use DeviceIoControl see e.g:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q165721

Regards
Friedrich
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 500 total points
ID: 16709005
That's actually not really complicated:

#include <windows.h>
#include <mmsystem.h> // link with 'winmm.lib'

void CDRomOpen(BOOL bOpenDrive, char *drive)
{
    MCI_OPEN_PARMS open;
    DWORD flags;

    ZeroMemory(&open, sizeof(MCI_OPEN_PARMS));

    open.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
    open.lpstrElementName = drive;

    flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;

    if (!mciSendCommand(0, MCI_OPEN, flags, (DWORD) &open))
    {
        mciSendCommand(open.wDeviceID, MCI_SET, (bOpenDrive) ?
                       MCI_SET_DOOR_OPEN : MCI_SET_DOOR_CLOSED, 0);
        mciSendCommand(open.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
    }
}
0
Technology Partners: 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 86

Expert Comment

by:jkr
ID: 16731296
Anything else you need to know about this issue?
0
 
LVL 6

Expert Comment

by:billtouch
ID: 16752784
This comment is to LeeTutor...

This is an operating specific question. The way you eject a cd is different in Windows Vs Linux. It is not a C language function to define device capabilites. If he can't see this, could someone pass this info along to him?

Bill
0
 
LVL 86

Expert Comment

by:jkr
ID: 16753864
>>The way you eject a cd is different in Windows Vs Linux

Yes, but how do you interpret 'windows sdk' in the title of the Q?
0
 
LVL 6

Expert Comment

by:billtouch
ID: 16754136
Just my point - its a Windows question.

There are no C constructs that talk to cd drives or anything other device. That happens through OS provided libraries. Every Os provides the libraries to do that. To be more exact, they come with the compiler but are unique to the OS.

This question is not a C language problem.

0
 
LVL 86

Expert Comment

by:jkr
ID: 16754179
>>Just my point - its a Windows question.

"I can move this to a more appropriate area if you tell me what language." vs. "C on Windows XP"

What kind of point are you trying to make?
0
 
LVL 6

Expert Comment

by:billtouch
ID: 16758088
My point is that the C language has nothing to do with what you can do to a cd drive. This forum is for questions about the C language. That, to me, includes syntax, algorithms and usage. It also includes the standard C libraries (i.e. strcpy, printf, and all similar os independent functions). The windows sdk is not a standard C library. It is a windows library that is accessable by C, pascal, Basic, assembler etc.

While you may use the C language to control a cd drive, you can also use any other language that has a compiler or interpreter on that OS.

In short, the title had it correct (windows sdk).

It is a Windows question.
0
 
LVL 86

Expert Comment

by:jkr
ID: 16765934
I am sorry to say so, but: If you would enforce that policy, this TA would be plain *empty* if any OS specifics (and there's more than just Windows) would be ruled out, such as any  EE TA that addresses a particular programming language. If you have any problems or resentments with questions related to Windows - ignore them.

BTW, this definietly *is* related to the C Programming Language. No doubt about that, noone asked for PASCAL code.
0

Featured Post

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!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

873 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