Website Design United States, Website Design California, Website Designing United States, Website Designing California

CD-ROM Drive Opener/Closer - Visual Basic 6

This code demonstrates how we can open and close the CD-ROM Drive using the SendMCIString API

'Attribute VB_Name = "Module1"
Option Base 1
Public 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

Sub main()
' CD Open/Close Program
' -Sanchit Karve
' You are allowed to distribute this code without making
' changes to it.
' -Sanchit Karve

Dim Now As String
Dim a(2) As String
a(1) = "set cdaudio door open"
a(2) = "set cdaudio door closed"
total = 1 'Set this to the number of cycles you want it to 'undergo
For i = 1 To (total * 2)
If Int(i / 2) = i / 2 Then
Now = vbString(a(2), 0)
Now = vbString(a(1), 0)
End If
Next i

End Sub
Function vbString(ByVal Command As String, ByVal hWnd As Long) As String
Dim Buff As String
Dim dwR As Long
Buff = Space$(100) ' Create a buffer
dwR = mciSendString(Command, ByVal Buff, Len(Buff), hWnd)
vbString = Buff
End Function

42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Tel: 91-011-40502005, 9810067295



© 2008-2009