This message was edited by ranainnet at 2005-9-20 13:29:56
This message was edited by ranainnet at 2005-9-20 13:27:14
: anyone know how to open to make the cdrom drive open and close using visual basic?
:
To open or close CD-ROM form VB uou need the following API:
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
Then you can open or close the cd-rom by the following code:
Public Sub OpenCD()
Dim res As Long, returnstring As String * 127
res = mciSendString("set CDAudio door open", returnstring, 127, 0)
End Sub
Public Sub CloseCD()
Dim res As Long, returnstring As String * 127
res = mciSendString("set CDAudio door closed", returnstring, 127, 0)
End Sub
'res is a Long variable
You can put those functions in a timer control to code a fun program which if loaded in the background will automatically oprn and close the CD-ROM tray.
GoodLuck.
_____________________________________________________________________________
Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->