Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CD_ROM Drive

Posted on 1999-07-22
1
Medium Priority
?
297 Views
Last Modified: 2010-04-30
How to detect/find a CD-ROM Drive?
0
Comment
Question by:galvani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
deighton earned 200 total points
ID: 1526567
     Private Const DRIVE_CDROM = 5
      Private Const DRIVE_FIXED = 3
      Private Const DRIVE_RAMDISK = 6
      Private Const DRIVE_REMOTE = 4
      Private Const DRIVE_REMOVABLE = 2
      Private Const DRIVE_UNKNOWN = 0    'Unknown, or unable to be determined.

      Public Declare Function GetDriveTypeA Lib "kernel32" (ByVal nDrive As String) As Long



Public Function CDletter() As String

    Dim x As String
    Dim c As Integer
   
    For c = 0 To 25
   
        x = Chr(Asc("a") + c) & ":\"
        If GetDriveTypeA(x) = DRIVE_CDROM Then
            CDletter = x
            Exit Function
        End If
       
    Next
       

End Function

      Public Function DriveType(sDrive As String) As String
         '
         ' Returns the drive type if possible.
         '
         Dim lRet As Long

         lRet = GetDriveTypeA(sDrive & ":\")
         Select Case lRet
            Case 0
               'DriveType = "Cannot be determined!"
               DriveType = "Unknown"

            Case 1
               'DriveType = "The root directory does not exist!"
               DriveType = "Unknown"
            Case DRIVE_CDROM:
               DriveType = "CD-ROM Drive"

            Case DRIVE_REMOVABLE:
               DriveType = "Removable Drive"

            Case DRIVE_FIXED:
               DriveType = "Fixed Drive"

            Case DRIVE_REMOTE:
               DriveType = "Remote Drive"
         End Select

      End Function

      Public Function GetDriveType(sDrive As String) As Long

         Dim lRet As Long
         lRet = GetDriveTypeA(sDrive & ":\")

         If lRet = 1 Then
            lRet = 0
         End If

         GetDriveType = lRet

      End Function


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question