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
Checking the presence of a disc in the drive
Collapse
X
-
Hi ... sorry it took a long time but here is the code i belive will work.Originally posted by vdraceilHi 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
[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] -
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
Comment