Home » System & API » How to list down all necessary Drive information
How to list down all necessary Drive information
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 'System & API - How to list down all necessary Drive information 'You need to set reference to Microsoft Scripting Runtime Public Function DriveInfo(Optional strDriveLetter As String = "C") Dim fldr As Folder Dim fso As New Scripting.FileSystemObject Dim drv As Scripting.Drive Dim strType As String 'Make sure there is only one drive letter If Len(strDriveLetter) > 1 Then MsgBox "Unknown Drive Letter" Exit Function End If 'Make sure the drive exists If Not fso.DriveExists(strDriveLetter & ":") Then MsgBox "Unknown Drive. Drive doesn't exist." Exit Function End If Set drv = fso.GetDrive(fso.GetDriveName(strDriveLetter & ":")) Debug.Print vbCrLf & "Drive Information for " & UCase$(strDriveLetter) & " Drive" Debug.Print "=============================" Debug.Print "Available space : " & FormatNumber(drv.AvailableSpace / 1024, 0) & " KB" Debug.Print "Drive letter : " & drv.DriveLetter Select Case drv.DriveType Case 0: strType = "Unknown" Case 1: strType = "Removable" Case 2: strType = "Fixed" Case 3: strType = "Network" Case 4: strType = "CD-ROM" Case 5: strType = "RAM Disk" End Select Debug.Print "Drive type : " & strType Debug.Print "Drive file system : " & drv.FileSystem Debug.Print "Drive free space : " & FormatNumber(drv.FreeSpace / 1024, 0) & " KB" Debug.Print "Drive is ready : " & drv.IsReady Debug.Print "Drive path : " & drv.Path Debug.Print "Root folder : " & drv.RootFolder Debug.Print "Serial number : " & drv.SerialNumber Debug.Print "Share name : " & drv.ShareName Debug.Print "Total size : " & FormatNumber(drv.TotalSize / 1024, 0) & " KB" Debug.Print "Volume name : " & drv.VolumeName End Function |
Related posts:
- How to get free disk space of C drive (in two ways)
- How to get OS information from the system (in two ways)
- How to find the number of a name, used in a numerology program
- How to List all the DLL files in the C:\WINDOWS\SYSTEM directory.
- How to Get Task Bar Information
- How to clear Start Menu -> Run MRU list
- How to return the drive type
- How to get Printer information like Status, Share Name, etc.
- How to get User’s local information
- How to list all the objects in a Database using DAO.
Enjoy this article?
Filed under: System & API
Leave a comment
Sponsors
Sponsors
Link Back to us
Donations
If you are benefited from this site, please donate a small contribution to us. It will help to maintain this site better.








