dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jan 16, 1998

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


CD-ROM Detection

Question:
How can I find the CD-Rom drive letter(s) from Visual Basic 5.0?

Answer:
The simplest method is to call the Win32 GetDriveType API against drives C:-Z:.

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

' GetDriveType return values
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6

Private Sub Form_Click()
  Dim i As Integer
  For i = Asc("C") To Asc("Z")
    If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then
      Debug.Print "Drive " & Chr(i) & ": is a CDROM."
    End If
  Next i
End Sub
Unfortunately, the Win16 GetDriveType doesn't offer this capability, and determining availability of a CDROM in that environment requires invoking DOS interrupts.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date