PDA

Click to See Complete Forum and Search --> : where is the CD-ROM drive?


Sep 12th, 2000, 03:47 PM
Take a look at this thread (http://forums.vb-world.net/showthread.php?threadid=18183) which shows how to determine the Drive letter and if there are any CDs in it.

hitcgar
Sep 12th, 2000, 04:14 PM
If what you're trying to do - I didn't quite get your point - is trying to find the CD drive
and it's letter then use WMI:


Public Sub listDrives(Optional strServer As String = ".")

Dim objs As WbemScripting.SWbemObjectSet
Dim obj As WbemScripting.SWbemObject
Dim svcs As WbemScripting.SWbemServices
Dim swLocator As WbemScripting.SWbemLocator

Set swLocator = New WbemScripting.SWbemLocator
Set svcs = swLocator.ConnectServer(strServer)
Set objs = svcs.InstancesOf("Win32_LogicalDisk")

For Each obj In objs
If obj.Properties_.Item("DriveType") = 5 Then
Debug.Print "Name: " & obj.Properties_.Item("Name")
Debug.Print "Drive Type: " & obj.Properties_.Item("DriveType")
End If
Next obj

Set objs = Nothing
Set svcs = Nothing
Set swLocator = Nothing
End Sub


Of course you need WMI installed on your sys which is avail. free from microsoft.

Sep 13th, 2000, 09:06 AM
Thanks for the help I wrote the code yesterday from the VBA Developer's Handbook it din't give me the correct results so I modified it with your code. Is there some way to prevent directory browsing on a CD so that an expiration date on the material there will be effective?