I used the following code to open and close the cd drive
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lRet As LonglRet = mciSendString("set CDAudio door open", vbNullString, 0, 0)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)HandlesButton2.Click Dim lRet As LonglRet = mciSendString(
"set CDAudio door closed", vbNullString, 0, 0) End Suband it does open and close it but instantly after it opens the program comes across this error
A call to PInvoke function 'Open And Close!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.
Can anyone help me with this Ive done forum searching on atleast five other sites but they all just give me examples of the same code that continues to give this error.

Open and close a CD DRIVE in visual basics 2005 express?
Geetha Srinivasan
nesoms
I think your Pinvoke declaration is incorrect
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal command As String, ByVal buffer As String, ByVal bufferSize As Int32, ByVal hwndCallback As IntPtr) As Int32
Use the following should work just fine....