VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Open/Close your CD-ROM easily

by $mTp (3 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Open and close your CDROM using the MCIsendstring API. I saw the program Heresy made, it's good but kind of complicated, newbies might not understand some stuff. I simply resolved the OPEN/CLOSE problem exploiting the Tag property of a command button. It's quite simple and reliable.

API Declarations
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

Rate Open/Close your CD-ROM easily

'create 2 command buttons, call the first one "Open" and the second one "Close"
'create a label 

Private Sub Form_Load()
command1.tag = "open"
Private Sub Command1_Click()
If Command1.Tag = "open" Then
retvalue = mciSendString("set CDAudio door open", _
returnstring, 127, 0)
Command1.Tag = "closed"
Else
retvalue = mciSendString("set cdaudio door closed", returnstring, 127, 0)
Command1.Tag = "open"
End If
Label1.Caption = Command1.Tag 'place a label to check to tag property of the command button

Download this snippet    Add to My Saved Code

Open/Close your CD-ROM easily Comments

No comments have been posted about Open/Close your CD-ROM easily. Why not be the first to post a comment about Open/Close your CD-ROM easily.

Post your comment

Subject:
Message:
0/1000 characters