Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleFind the first CD drive letter
Keywordscd drive, drive, cd-rom
CategoriesWindows
 
Use the GetDriveType API function to check the types of drives A, B, C, etc. until you find a CD drive.
 
' Return the first CD-ROM drive letter.
' Return "" if we cannot find a CD drive.
Private Function FirstCDDrive() As String
Const ASC_A = 65
Const ASC_Z = ASC_A + 25

Dim i As Integer

    For i = ASC_A To ASC_Z
        If GetDriveType(Chr$(i) & ":\") = DRIVE_CDROM Then
            FirstCDDrive = Chr$(i)
            Exit For
        End If
    Next i
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated