Error when I try to open cdrom programmatically
- From: "Victor" <shigang1(-at-)21cn(-dot-)com>
- Date: Wed, 27 Sep 2006 14:42:20 +1200
Hi guys
when i try to open my cdrom with "mciSendString" API Call. i get exception.
but i have no idea how this happen. Can you guys give me some idea? Thanks
My code likes:
[DllImport("winmm.dll", EntryPoint = "mciSendStringA")]
private static extern long mciSendString(string lpstrCommand, string
lpstrReturnString, long uReturnLength, long hwndCallback);
private long retvalue;
private string returnstring = string.Empty;
private void button1_Click(object sender, EventArgs e)
{
CDControl(true);
}
private void CDControl(bool action)
{
if (action)
{
// open the CDROM
retvalue = mciSendString("set CDAudio door open",
returnstring, 127, 0);
}
else
{
// Close the CDROM
retvalue = mciSendString("set CDAudio door closed",
returnstring, 127, 0);
}
}
The exception is
PInvokeStackImbalance was detected
Message: A call to PInvoke function
'WindowsApplication1!WindowsApplication1.Form1::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.
.
- Follow-Ups:
- Re: Error when I try to open cdrom programmatically
- From: Chris Taylor
- Re: Error when I try to open cdrom programmatically
- Prev by Date: DataGridView - Sort Multiple Columns
- Next by Date: How does windows forms message routing work?
- Previous by thread: DataGridView - Sort Multiple Columns
- Next by thread: Re: Error when I try to open cdrom programmatically
- Index(es):