Determine Disk Type
No attachments for this post
Given a drive letter, returns the type of disk present, if connected.
'lpRootPathName : string that specifies the root directory of the disk to return information about. If lpRootPathName is an empty string, the function uses the root of the current directory.
Public Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Public Const DRIVE_UNKNOWN = 0
Public Const DRIVE_DOES_NOT_EXIST = 1
Public Const DRIVE_REMOVABLE = 2
Public Const DRIVE_FIXED = 3
Public Const DRIVE_REMOTE = 4
Public Const DRIVE_CDROM = 5
Public Const DRIVE_RAMDISK = 6
Private Sub Command1_Click()
'Get the type of the D:\ Drive
Select Case GetDriveType("D:\")
MsgBox "Type Unknown", vbExclamation
MsgBox "Type Unknown", vbCritical
MsgBox "The disk can be removed from the drive", vbInformation
MsgBox "The disk can not be removed from the drive", vbInformation
MsgBox "The drive is a remote (network) drive", vbInformation
MsgBox "The drive is a CD-ROM drive", vbInformation
MsgBox "The drive is a RAM disk", vbInformation
This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.