Open CD Rom Drive using C# Code

The below code is used to open CD Rom Drive

//Namespace need to referenced

using System.Text;

using System.Runtime.InteropServices;

//Win32 Api need to call

//Write this as a function

[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]

protected static extern int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback);

//Call the below function from any of the function where you want to open the CDRom Drive

int ret = mciSendString("Open CD door", null, 0, IntPtr.Zero);


Submitted By Nipesh Shah @ 10/3/2011 10:30:07 AM

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...