VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



ULTIMATE CD Function

by zOnE (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This Code opens and closes the cd-rom drive at a given interval. This can be used for security purposes and just for laughs. (though cruel laughs they would be ) This code is great for beginners. It shows how to use a timer in a very simple way.

Inputs
n/a
Assumes
Needs two command buttons (optional but highly recommended) and a timer named Timer1.
Code Returns
Opens and closes cd door.
Side Effects
None unless you make it so that the timer will never be disabled.
API Declarations
Declare Function mciSendString Lib "MMSystem" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal wReturnLength As Integer, ByVal hCallback As Integer) As Long

Rate ULTIMATE CD Function

' This should work with ALL versions of VB, BUT 
' It was only tested with VB4 (16-Bit). I will
' Be sure to test it on VB6. Just Follow the code
' Below
Make a timer and name it Timer1
 Set its Enabled property to False
Now set its Interval Property to the time you want the action to occur.
Make 2 command buttons. 
Label 1 of them ON
 and
the other OFF.
'In Timer1 Place the following code
retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0) 
retvalue = mciSendString("set CDAudio door closed", returnstring, 127,0)
' In Command1 labeled On place the following code
Timer1 = Enabled
' In Command2 labeled OFF place the following code
Timer1 = Disbaled

Download this snippet    Add to My Saved Code

ULTIMATE CD Function Comments

No comments have been posted about ULTIMATE CD Function. Why not be the first to post a comment about ULTIMATE CD Function.

Post your comment

Subject:
Message:
0/1000 characters