Rubrik: Dateisystem · Laufwerke | VB-Versionen: VB4, VB5, VB6 | 05.10.06 |
Dateisystem eines Laufwerks ermitteln Dieser Tipp zeigt, wie man das Dateisystem (FAT, NTFS) eines übergebenen Laufwerks ermittelt. | ||
Autor: Microsys Kramer | Bewertung: | Views: 9.103 |
www.access-paradies.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Mit nachfolgendem Code lässt sich das verwendete Dateisystem (FAT, NTFS, ...) eines bestimmten Laufwerks ermitteln.
Fügen Sie den Code am besten in ein Modul:
Option Explicit ' Benötigte API-Deklarationen Private 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
' Ermittelt das Dateisystem eines Laufwerks (FAT, NTFS usw.) ' Aufruf: FileSystemName("C:\") Public Function FileSystemName(ByVal Drive As String) As String Dim lAns As Long Dim lRet As Long Dim sVolumeName As String Dim sDriveType As String Dim 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) FileSystemName = sDriveType End Function