How to check whether the file system is FAT 32 or NTFS
Posted on January 5, 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 | 'System & API - How to check whether the file system is FAT 32 or NTFS Declare Function GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" _ (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, _ lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _ ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Function FileSystem(ByVal Drive As String) As String Dim lAns As Long, lRet As Long Dim sVolumeName As String, sDriveType As String, sDrive As String Dim iPos As Integer sDrive = Drive If Len(sDrive) = 1 Then sDrive = sDrive & ":\" ElseIf Len(sDrive) = 2 And Right(sDrive, 1) = ":" Then sDrive = sDrive & "\" End If sVolumeName = String$(255, Chr$(0)) sDriveType = String$(255, Chr$(0)) lRet = GetVolumeInformation(sDrive, sVolumeName, 255, lAns, 0, 0, sDriveType, 255) iPos = InStr(sDriveType, Chr$(0)) If iPos > 0 Then sDriveType = Left(sDriveType, iPos - 1) FileSystem = sDriveType End Function Private Sub Main() MsgBox "The file system of drive C: is: " & FileSystem("C:") End Sub |