473,545 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Eject a CD

How can I eject a CD tray (Drive Letter is known)?

Thx~
Jul 21 '05 #1
2 3755
Hi,

[DllImport( "winmm.dll" , EntryPoint="mci SendStringA",
CharSet=CharSet .Ansi )]
protected static extern int mciSendString( string lpstrCommand,
StringBuilder lpstrReturnStri ng,
int uReturnLength,
IntPtr hwndCallback );

To open CDRom Tray:

string strDriveLetter = "E";
mciSendString( "open "+strDriveLette r+":\\ type cdaudio alias cdrom",
null, 0, IntPtr.Zero );
int ret = mciSendString( "set cdrom door open", null, 0, IntPtr.Zero );
mciSendString( "close cdrom", null, 0, IntPtr.Zero );

To close CDRom Tray:
string strDriveLetter = "E";
mciSendString( "open "+strDriveLette r+":\\ type cdaudio alias cdrom",
null, 0, IntPtr.Zero );
int ret = mciSendString( "set cdrom door closed", null, 0, IntPtr.Zero
);
mciSendString( "close cdrom", null, 0, IntPtr.Zero );

Cheers.

Eyal.

Jul 21 '05 #2
Thx~.
"Eyal Safran" <ey**@mokedor.c om> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi,

[DllImport( "winmm.dll" , EntryPoint="mci SendStringA",
CharSet=CharSet .Ansi )]
protected static extern int mciSendString( string lpstrCommand,
StringBuilder lpstrReturnStri ng,
int uReturnLength,
IntPtr hwndCallback );

To open CDRom Tray:

string strDriveLetter = "E";
mciSendString( "open "+strDriveLette r+":\\ type cdaudio alias cdrom",
null, 0, IntPtr.Zero );
int ret = mciSendString( "set cdrom door open", null, 0, IntPtr.Zero );
mciSendString( "close cdrom", null, 0, IntPtr.Zero );

To close CDRom Tray:
string strDriveLetter = "E";
mciSendString( "open "+strDriveLette r+":\\ type cdaudio alias cdrom",
null, 0, IntPtr.Zero );
int ret = mciSendString( "set cdrom door closed", null, 0, IntPtr.Zero
);
mciSendString( "close cdrom", null, 0, IntPtr.Zero );

Cheers.

Eyal.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2941
by: Prakru | last post by:
Hello guys, I get compilation error for the following code in MS VC++ 6 compiler: I thought that if the Eject is called with no args, then the Player::Eject () should be called. But it is not working.
1
7622
by: Hai Ly Hoang [MT00KSTN] | last post by:
In my application, i want to flush all data to USB and eject it (like select Safe Remove from tray icon). Is it possible ? How to to that ? Thanks a lot
3
3664
by: Tony | last post by:
I wish to be able to eject either a pc card or compact flash card programmatically Is there any way to achieve this in with C#? TIA Tony
0
2594
by: MT00KSTN - Hai Ly Hoang | last post by:
In my application, I want to command to eject the USB drive (flash disk) (like select Safe Remove from the tray icon). How to do that ? Thank in advance
4
22798
by: Maheshkumar.R | last post by:
Hi all, I want to access, detect, eject(open and close) CD Rom using C#. How i can do this..? -- Mähésh Kumär. R cyberiafreak
2
291
by: Allen St.Clair | last post by:
How can I eject a CD tray (Drive Letter is known)? Thx~
3
2572
by: Joe Cool | last post by:
OK, I know you have to be able to do this. I have searched VB help, this newsgroup, and google in general and I can't find any sample code or instructions on how to eject the cd/dvd device tray from VB code. Someone PLEASE help!!!
0
2435
by: David Penne | last post by:
I have SBS 2003 and am using the built in tape backup. My question is about the registry key "Eject Tape Flag". I understand that this is an undocumented key and the only articles I can find about it on the internet reference NT 4.0. Does anyone know if this key works? I have users that would like to eject the tape after a backup and...
4
2169
by: John Devlon | last post by:
Hi Does anyone know how to eject a cd/dvd on a drive? Thanx John
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.