Results 1 to 15 of 15

Thread: Opening/Closeing CD tray 1/2 or browseing

  1. #1

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456

    Opening/Closeing CD tray 1/2 or browseing

    I'm trying to do something, and when the user clicks on the open button it well load up a dialog box (that I made) that well ask if the user what's to open his/her CD tray 1 or 2 (if they have 2 cd drives) and one the let's them browse there computer for media files (mpg, avi, mp3, etc.). this is what I got so far:

    Look at next post for the picture.

    All I need now is the code for doing that and how to I do a form load thing that well scan there drive(s) for the name of the CD drive(s) and howmany there, and if it scans and finds only one, it well hide option2 showing a message that reads "No second CD Drive found" and if it finds the name it well say something like (by the option thing replaceing "Open/Close CD Tray 1" with "Open/Close *name of CD Drive*"):

    Open/Close *Name of CD Drive*

    Thank you a head of time.
    Last edited by scsa20; Aug 2nd, 2001 at 10:22 AM.


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  2. #2

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    since the link didn't worked (for some reason) when you click on it to see what it looks like, I just added it as a attachment (alot easyer).


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  3. #3

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    anyone??


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  4. #4

  5. #5
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    Once you know what the drive letters are for the various CD drive(s) on the system (all that info is in those 3 links), this can be used to open or close those doors.
    VB Code:
    1. 'in a module
    2. Public Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpzCommand As String, ByVal lpzReturn As String, ByVal nReturnLength As Long, ByVal hWndCallback As Long) As Long
    3.  
    4. Public Sub DriveDoor(ByVal strDriveLetter As String, Optional ByVal blnOpenDoor As Boolean = True)
    5.    'tells the MCI to ready the device and nickname it "dooralias"
    6.    mciSendString "open " & strDriveLetter & ": type cdaudio alias dooralias", vbNullString, 0, 0
    7.    'opens/closes the given drive door based on the boolean flag
    8.    mciSendString "set dooralias door " & IIf(blnOpenDoor, "open", "closed"), vbNullString, 0, 0
    9.    'tells MCI that we're done with the device
    10.    mciSendString "close dooralias", vbNullString, 0, 0
    11. End Sub
    12.  
    13. 'to open the door of drive X
    14. DriveDoor "x", True  'true is assumed, and may be left out
    15.  
    16. 'to close the door of drive X
    17. DriveDoor "x", False
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  6. #6
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411

    Heres how to get the drive letters

    VB Code:
    1. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    2.  
    3. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
    4.  
    5. Private Declare Function mciSendString Lib "winmm.dll" Alias _
    6.     "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
    7.     lpstrReturnString As String, ByVal uReturnLength As Long, _
    8.     ByVal hwndCallback As Long) As Long
    9.  
    10. Const DRIVE_CDROM = 5
    11.  
    12. Private Sub Command1_Click()
    13.     Dim tmp As Integer
    14.     Dim tmpStr As String
    15.     Dim Drives As String
    16.     Dim CDsCount As Integer 'Number of CD Drives
    17.     Dim CDsLetters As String 'Cd Drive Letters
    18.     Drives = Space(255)
    19.     ret& = GetLogicalDriveStrings(Len(Drives), Drives)
    20.  
    21.  
    22.     For tmp = 1 To ret& Step 4
    23.  
    24.         tmpStr = Mid(Drives, tmp, 3)
    25.  
    26.  
    27.         If GetDriveType(tmpStr) = DRIVE_CDROM Then
    28.             CDsCount = CDsCount + 1
    29.             CDsLetters = CDsLetters & Left(tmpStr, 1) & " "
    30.         End If
    31.     Next tmp
    32.  
    33.  
    34.     If CDsCount Then
    35.         MsgBox CDsCount, vbInformation, "Number Of CD Drives"
    36.         MsgBox CDsLetters, vbInformation, "Letters Of Drives"
    37.     Else
    38.         MsgBox "No CDs Available"
    39.     End If
    40. End Sub
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  7. #7
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411

    oops

    the MCI SENDSTRING declaration doesn't need to be there LOL i took this from another program i had made hehe
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  8. #8

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    thanks for the codes and links, I'll try them out.


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  9. #9

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    Ok, I tryed out the code that AGG and Kaverin give me, but how do I put the code that AGG give me that renames the caption of the first CD Drive in the first Option slecte and renames the caption of the second CD Drive in the second Option slecte?? Plus how do I use the code that Kaverin gived me for opening the first cd drive (when slected) and for opening the second cd drive (when slected) and for opening up a browse screen that lets you look for mpgs, avis, mp3, etc. (when slected)??


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  10. #10

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    anyone??


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  11. #11

  12. #12

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    Originally posted by chenko
    http://members.aol.com/vbchenko/download/eg/cdrive.zip

    there you go...
    it says it can't find the page (well...that what I get)


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  13. #13

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    anyone??


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

  14. #14
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Something like the app attached?

  15. #15

    Thread Starter
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    hey, thanks. Now I can actly look at a program that has that list thing and take a look at it and brak it down to fit in my program I'm making.


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width