Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    5

    Unanswered: Sys Variable that holds Driver letter of DVD?

    Is there a variable (or technique) that allows me to determine what the drive letter of the DVD-drive is and use that variable in Visual Basic code? Thanks for any help. This one has me stumped.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try this, (it's originally a vbscript: too lazy to convert in proper VBA tonight):
    Code:
    Function Find_CDROM_Drives()
    
        Dim strComputer As String
        Dim objWMIService As Object
        Dim colItems As Object
        Dim objItem As Object
        
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
        For Each objItem In colItems
            Debug.Print "Device ID: " & objItem.DeviceID
            Debug.Print "Description: " & objItem.Description
            Debug.Print "Name: " & objItem.Name
            Debug.Print "Drive: " & objItem.Drive
        Next
        
    End Function
    Have a nice day!

  3. #3
    Join Date
    Jun 2009
    Posts
    5

    Thanks!

    That did the trick. Thanks for you helpl.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •