Jul 24, 2001 #1 Kori Programmer Oct 17, 2000 35 US I am in the need of finding out what Drive I am currently on. For example if you go to the properties of your hard disk it says Type: Local Disk Or for the network: Type: Network Connection Anyone know how to go get these?
I am in the need of finding out what Drive I am currently on. For example if you go to the properties of your hard disk it says Type: Local Disk Or for the network: Type: Network Connection Anyone know how to go get these?
Jul 27, 2001 #2 wanmaster Programmer Nov 20, 2000 94 NL Two ways of doing it: using API or the FileSystemObject.. *** API *** Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long 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 GetDriveTypeWithAPI() Dim liDriveType As Long Dim lsDescription As String liDriveType = GetDriveType("c:\" Select Case liDriveType Case 2: lsDescription = "Removable" Case 3: lsDescription = "Fixed" Case 4: lsDescription = "Network" Case 5: lsDescription = "CD-ROM" Case 6: lsDescription = "RAM Disk" Case Else: lsDescription = "Unknown" End Select MsgBox "Drive type: " & lsDescription End Sub *** FSO *** Private Sub GetDriveTypeWithFSO() Dim loFSO As FileSystemObject Dim loDrive As Drive Dim lsDescription As String Set loFSO = New FileSystemObject Set loDrive = loFSO.GetDrive("c:\" Select Case loDrive.DriveType Case 0: lsDescription = "Unknown" Case 1: lsDescription = "Removable" Case 2: lsDescription = "Fixed" Case 3: lsDescription = "Network" Case 4: lsDescription = "CD-ROM" Case 5: lsDescription = "RAM Disk" End Select MsgBox "Drive type: " & lsDescription Set loFSO = Nothing End Sub Remedy Upvote 0 Downvote
Two ways of doing it: using API or the FileSystemObject.. *** API *** Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long 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 GetDriveTypeWithAPI() Dim liDriveType As Long Dim lsDescription As String liDriveType = GetDriveType("c:\" Select Case liDriveType Case 2: lsDescription = "Removable" Case 3: lsDescription = "Fixed" Case 4: lsDescription = "Network" Case 5: lsDescription = "CD-ROM" Case 6: lsDescription = "RAM Disk" Case Else: lsDescription = "Unknown" End Select MsgBox "Drive type: " & lsDescription End Sub *** FSO *** Private Sub GetDriveTypeWithFSO() Dim loFSO As FileSystemObject Dim loDrive As Drive Dim lsDescription As String Set loFSO = New FileSystemObject Set loDrive = loFSO.GetDrive("c:\" Select Case loDrive.DriveType Case 0: lsDescription = "Unknown" Case 1: lsDescription = "Removable" Case 2: lsDescription = "Fixed" Case 3: lsDescription = "Network" Case 4: lsDescription = "CD-ROM" Case 5: lsDescription = "RAM Disk" End Select MsgBox "Drive type: " & lsDescription Set loFSO = Nothing End Sub Remedy