Checking the presence of a disc in the drive

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vdraceil
    New Member
    • Jul 2007
    • 236

    Checking the presence of a disc in the drive

    Hi friends,i just wanna know whether the presence of a disc in the drive can be detected by coding in vb6.0..if the disc is present i want to perform a set of actions, else i want to display 'insert disc please'..Expert s kindly help
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by vdraceil
    Hi friends,i just wanna know whether the presence of a disc in the drive can be detected by coding in vb6.0..if the disc is present i want to perform a set of actions, else i want to display 'insert disc please'..Expert s kindly help
    Hi ... sorry it took a long time but here is the code i belive will work.
    [CODE=vb]Private Sub Command1_Click( )
    Dim Drive As String
    Drive = "D:\"
    Dim Rename As String
    Rename = FileSystem.Dir( Drive, vbVolume)

    If Len(Rename) = 0 Then
    If MsgBox("There is no Disk Present", vbCritical + vbRetryCancel) = vbRetry Then
    Command1_Click
    End If
    Else
    MsgBox (Rename & " Is in the Drive")
    End If

    End Sub[/CODE]
    Last edited by debasisdas; Jan 4 '08, 11:18 AM. Reason: formatted using code tags

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      There's another alternative. Add a reference to Microsoft Scripting Runtime to your project. And add a command button, of course. Then try this...

      [CODE=vb]Private Sub Command1_Click( )
      Dim fso As New FileSystemObjec t
      Dim drv As Drive
      For Each drv In fso.Drives
      Me.Print drv.DriveLetter , drv.DriveType, drv.IsReady
      End With
      Next
      End Sub[/CODE]

      Comment

      Working...