V
Victor
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.
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.