Tools Links Login

ULTIMATE CD Function

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.

Original Author: zOnE

Inputs

n/a

Assumptions

Needs two command buttons (optional but highly recommended) and a timer named Timer1.

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

Code

' 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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 81 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.