 |
|
|
 |
|
 |
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]
protected static extern int mciSendString(string lpstrCommand,
StringBuilder
lpstrReturnString,
int uReturnLength,
IntPtr hwndCallback);
private void button1_Click(object sender, EventArgs e)
{
int ret = mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
}
private void button2_Click(object sender, EventArgs e)
{
int ret = mciSendString("set cdaudio door closed", null, 0, IntPtr.Zero);
}
I'm not exactly sure what it does if you have more than 1 drive, or what...
It works if my DVD Rom is my D: though :p
|
|
|
|
 |
|
 |
Hello!
When I debug a program open/close CD ROM, I see an error :
A call to PInvoke function 'RFID-DEMO!RFID_DEMO.Class1::mciSendString' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Please tell me how to fix it, thanks!
|
|
|
|
 |
|
 |
I forgot to free the allocated memory in the ProcessCommandLine function.
...
if (argc >= 3)
{
if (!lstrcmp(argv[1], "open"))
*cmd = TRUE;
else if (!lstrcmp(argv[1], "close"))
*cmd = FALSE;
else
{
fHelp = TRUE;
free((void *) argv);
return 0;
}
wsprintf(drive, "%c:", argv[2][0]);
}
else
{
fHelp = TRUE;
free((void *) argv);
return 0;
}
free((void *) argv);
return 0;
}
|
|
|
|
 |
|
 |
Compile error? Any idea how to fix it?
In function `Z9CDRomOpeniPc':
[Linker error] undefined reference to `mciSendCommandA@16'
[Linker error] undefined reference to `mciSendCommandA@16'
[Linker error] undefined reference to `mciSendCommandA@16'
ld returned 1 exit status
|
|
|
|
 |
|
 |
You need to add Winmm.lib to the list of library modules for the linker.
|
|
|
|
 |
|
 |
I have a CD/DVD drive F and a CD/DVD writer drive G
Regardless of the drive specified, only drive F opens even if I specify drive G.
Jon
|
|
|
|
 |
|
 |
I've got a USB CD on D: and a USB DVD on E:. I plugged in the following code (adjusted for newest visual studio) for quick testing purposes.
void CDVDListPrinterApp::OnFileEjectDriveTray()
{
MCI_OPEN_PARMS open;
DWORD flags;
ZeroMemory(&open, sizeof(MCI_OPEN_PARMS));
open.lpstrDeviceType = (LPCTSTR) MCI_DEVTYPE_CD_AUDIO;
open.lpstrElementName = _T("E:");
flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;
if (!mciSendCommand(0, MCI_OPEN, flags, (DWORD_PTR) &open))
{
mciSendCommand(open.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
mciSendCommand(open.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
}
}
and
void CDVDListPrinterApp::OnFileLoadDriveTray()
{
MCI_OPEN_PARMS open;
DWORD flags;
ZeroMemory(&open, sizeof(MCI_OPEN_PARMS));
open.lpstrDeviceType = (LPCTSTR) MCI_DEVTYPE_CD_AUDIO;
open.lpstrElementName = _T("E:");
flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;
if (!mciSendCommand(0, MCI_OPEN, flags, (DWORD_PTR) &open))
{
mciSendCommand(open.wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0);
mciSendCommand(open.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
}
}
If I turn off the D: drive, I eject the DVD just fine, but if both drives are active I only eject the first drive.
|
|
|
|
 |
|
 |
I've figured out a solution. Add | MCI_OPEN_ELEMENT or | MCI_OPEN_ELEMENT_ID to the flags, and it will pay attention to the name of the drive. I'm not sure which is the correct flag to use, as both seemed to work in my case.
Either way, using the MCI commands is much easier than using ASPI commands, which I was close to resorting to.
Wim.
|
|
|
|
 |
|
 |
Hi there, good work. I'd make the following suggestion. Put somewhere a note that MCI_SET_DOOR_CLOSE works only with a particular CDROM. For example, CDROMs on laptops does not have a mechanism for closing, and therefore MCI_SET_DOOR_CLOSE will not work properly.
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
 |
|
 |
It's just what i want to remember my collegues to backup their work of the day!
|
|
|
|
 |
|
 |
It's just what I wanted!
5 stars!
(W2K SP4)
|
|
|
|
 |
|
|
 |
|
 |
It does not work on Windows 2003.
Could you show me how to make it work.
|
|
|
|
 |
|
 |
I will try it at work because I haven't Windows 2003 at home.
|
|
|
|
 |
|
|
 |
|
 |
Yeah it doesn't do anything for me either
|
|
|
|
 |
|
 |
Help Please
1. how check cd writter (how many copy Writted)
2. how check the printer(how many pages prited)
3. how to find how many MB download from internet
|
|
|
|
 |
 | demo  |  | Anonymous | 9:02 28 Sep '05 |
|
 |
cdrom open F works but not
cdrom close F
Maybe not all CD drives support close??
|
|
|
|
 |
|
 |
dunno, i think it is standerd for all cd drives.
|
|
|
|
 |
|
 |
It works. Tested on WinXP and Win2k.
|
|
|
|
 |
|
 |
As far as I've messed around with this, open command sometimes fails if there's no disk in the drive( ?), not sure about closing though..
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
http://sprd.12.forumer.com
Our forum features..err..nothing. You're welcome to contribute.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
 |