|
-
Jun 29th, 2005, 10:07 PM
#1
Thread Starter
Junior Member
POP UP message if there is no media in the CDROM
Anybody has code to prompt message if there is no media in the cdrom! (Visual basic or vb script is what I am looking for!)
Thanks
Dali
-
Jun 29th, 2005, 10:36 PM
#2
Re: POP UP message if there is no media in the CDROM
This works:
VB Code:
Option Explicit
Private Sub Form_Load()
On Error GoTo trap
MsgBox Dir("g:")
Exit Sub
trap:
If Err.Number = 52 Then
MsgBox "No disk in drive"
End If
End Sub
-
Jun 29th, 2005, 10:40 PM
#3
Re: POP UP message if there is no media in the CDROM
Try using FSO:
VB Code:
Private Sub Command1_Click()
'===============================
Dim fso As New FileSystemObject
Dim drv As Drive
Set drv = fso.GetDrive("e:\")
If drv.DriveType = CDRom Then
If drv.IsReady = False Then
MsgBox "No media found"
End If
End If
End Sub
-
Jun 29th, 2005, 10:42 PM
#4
Thread Starter
Junior Member
Re: POP UP message if there is no media in the CDROM
That would work, but in many cases I won't know the drive letter for the cdrom!
-
Jun 29th, 2005, 10:47 PM
#5
Re: POP UP message if there is no media in the CDROM
There can be many Disks that have removeable media. You could just start at "C:" and work your way up, I guess. Check for "\autorun.inf" if it's present, then it's most likely an autorun cd
-
Jun 29th, 2005, 10:49 PM
#6
Re: POP UP message if there is no media in the CDROM
Just loop through drives:
VB Code:
Private Sub Command1_Click()
'===============================
Dim fso As New FileSystemObject
Dim drv As Drive
For Each drv In fso.Drives
If drv.DriveType = CDRom Then
If drv.IsReady = False Then
MsgBox "Drive " & drv.DriveLetter & " has no media."
End If
End If
Next drv
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|