Results 1 to 4 of 4

Thread: cd tray insert notification

  1. #1

    Thread Starter
    Lively Member The_Fog's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    65

    cd tray insert notification

    Are there any way to know if there is a disc in the cd/dvd-player without searching for any files? Is there a flag set somewhere in windows when a disc is inserted?
    They will try to steal everything you own,
    It goes on and on and on...


    Pain - On and On

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 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
    2.  
    3. Private Function IsCDInDrive(ByVal strCDDriveLetter As String) As Boolean
    4.    Dim strStatus As String * 128
    5.    'open the device
    6.    mciSendString "open " & strCDDriveLetter & ": type cdaudio alias cddrive wait", vbNullString, 0, 0
    7.    'see if there's something in the drive
    8.    mciSendString "status cddrive media present", strStatus, Len(strStatus), 0
    9.    'close the device
    10.    mciSendString "close cddrive", vbNullString, 0, 0
    11.    'the string will contain "true" or "false" which can be easily converted
    12.    IsCDInDrive = CBool(Left$(strStatus, InStr(strStatus, vbNullChar) - 1))
    13. End Function

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    or u can use FSO

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim fso As New FileSystemObject
    3.     Dim drv As Drive
    4.     Set drv = fso.GetDrive("A:")
    5.     If drv.IsReady Then
    6.         MsgBox "drive is ready"
    7.     Else
    8.         MsgBox "drive not ready"
    9.     End If
    10. End Sub
    -= a peet post =-

  4. #4

    Thread Starter
    Lively Member The_Fog's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    65
    Thanks! Works great. :-)
    They will try to steal everything you own,
    It goes on and on and on...


    Pain - On and On

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