logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 How to open and close CD-ROM drive

Posted on
2/18/2001
Author:
Robert Gelb
Email:
Not Shown
Applies To OS:
NT, 9x, 2000
Product:
4, 5, 6



Occasionally, we all want to write a program that will goof on someone. Why not write a program that opens and closes the CD-ROM drive constantly? Here is how:

Add the following to a Form, Module or Class Module

Option Explicit

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

Public Sub OpenCdDoor()
    Dim sReturn As String
    Const RETURN_SIZE = 127
    
    mciSendString "set Cdaudio door open", sReturn, RETURN_SIZE, 0
End Sub

Public Sub CloseCdDoor()
    Dim sReturn As String
    Const RETURN_SIZE = 127
    
    mciSendString "set Cdaudio door closed", sReturn, RETURN_SIZE, 0
End Sub

Remarks

Call the two public functions OpenCdDoor and CloseCdDoor whenever you need to accomplish the task.



Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word:
 



Comments
#1. By alice. Posted on 5/13/2009 3:50:54 PM
But what I have to do with this text?