I want to program a small program in C # in windows that open the CD drive - extract the CD if someone is . I would like to know where I start from and whether the pure library deals with this idea. Thanks to all the difficulties for opening and closing a disk drive in a CD, it is not difficult for the useful API function.
First you will need to define a function to open the disk tray:
[DllImport ("winmm.dll", EntryPoint = "mciSendString")] Public stable extern Int mciSendStringA (string lpstr commands, string lpstrReturnString, int uReturnLength, int hwnd callback);
If the above code does not compile, try adding the following source # line to the top of your source code:
System.Runtime.InteropServices use;
Open the disk drive
To open the disk drive, you need to use two command strings mciSendStringA first on a desired drive Give a name. The second command will actually open the disk tray:
mciSendStringA ("open" + driveLetter + ": type cd audio aka drive" + drive liter, return string, 0, 0); MciSendStringA ("set drive" + drive liter + "open the door", return string, 0, 0); will be the first one to close the disk drive, the second command will now close the disc tray :
mciSendStringA ("open" + drive liter + ": type cdroid arrow drive" + drive liter, return string, 0, 0); MciSendStringA ("Set Drive" + Drive Litter + "Door Lock", Return String, 0, 0);
Comments
Post a Comment