Results 1 to 4 of 4

Thread: What Drive Letter is CDROM?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Glasgow, MT, USA
    Posts
    44
    How do I get the letter of the CDROM drive? Or get the root directory of the drive my program is on?

  2. #2
    Guest
    Hello,

    I never needed to find the CD, but to figure out what drive your app is on try this:
    Code:
    MsgBox Left(App.Path, 2)
    Hope this helps,

  3. #3
    New Member
    Join Date
    May 2000
    Location
    Belgium
    Posts
    8
    Hi !

    I have code for finding CD_ROM(s) :

    In Declare module:

    Declare Function GetLogicalDriveStrings Lib "kernel32.dll" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long


    Public Const DRIVE_REMOVABLE = 2 'A floppy drive or some other removable-disk drive.
    Public Const DRIVE_FIXED = 3 'A hard drive.
    Public Const DRIVE_REMOTE = 4 'A network drive or a drive located on a network server.
    Public Const DRIVE_CDROM = 5 'A CD-ROM drive.
    Public Const DRIVE_RAMDISK = 6 'A RAM disk.

    In Execution Module: (Form or others ...)

    Private Sub Command1_Click()

    Dim strdrivenames As String
    Dim strthisdrive As String

    Dim lngcpt As Long
    Dim lnglength As Long
    Dim lngdrivetype As Long

    strdrivenames = Space(255)
    lnglength = GetLogicalDriveStrings(255, strdrivenames)

    For lngcpt = 1 To lnglength Step 4
    strthisdrive = Mid(strdrivenames, lngcpt, 3)
    lngdrivetype = GetDriveType(strthisdrive)

    Select Case lngdrivetype
    Case DRIVE_REMOVABLE: MsgBox strthisdrive & " is a removable-disk drive."
    Case DRIVE_FIXED: MsgBox strthisdrive & " is a hard drive."
    Case DRIVE_REMOTE: MsgBox strthisdrive & " is a network drive or a drive located on a network server."
    Case DRIVE_CDROM: MsgBox strthisdrive & " is a CD-ROM drive."
    Case DRIVE_RAMDISK: MsgBox strthisdrive & " is a RAM disk."
    Case Else: MsgBox strthisdrive & " comes from X-Files ."
    End Select

    Next lngcpt


    End Sub

    You can limit the test of lngdrivetype to DRIVE_CDROM of course


    I hope it's oki for you ... bye.


  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Glasgow, MT, USA
    Posts
    44

    Thumbs up

    Thanks, Im sure that code will come in handy. But for now, I just opened to root Directory by useing " ..\ " to back one directory. Thanks again

Posting Permissions

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



Click Here to Expand Forum to Full Width