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
| Option Explicit
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" ( _
ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long _
) As Long
Private Const MAX_PATH = 260
Private Sub Form_load()
Dim strRacine As String, strVolumeName As String, strFileSystemName As String
Dim lSerialNumber As Long, lpMaximumComponentLength As Long, lFileSystemFlag As Long
' Initialisations
strRacine = "C:\"
strVolumeName = String$(MAX_PATH, Chr$(0))
strFileSystemName = String$(MAX_PATH, Chr$(0))
' Appel de l'API
If GetVolumeInformation(strRacine, strVolumeName, MAX_PATH, lSerialNumber, lpMaximumComponentLength, lFileSystemFlag, strFileSystemName, MAX_PATH) Then
strVolumeName = Left$(strVolumeName, InStr(strVolumeName, Chr$(0)) - 1)
strFileSystemName = Left$(strFileSystemName, InStr(strFileSystemName, Chr$(0)) - 1)
'MsgBox "Chemin du volume : " & strRacine
'MsgBox "Nom du volume : " & strVolumeName
MsgBox "Numéro de série : " & lSerialNumber
'MsgBox "Longueur maximale d'un composant d'un nom de fichier : " & lpMaximumComponentLength
'MsgBox "System flags : " & lFileSystemFlag
'MsgBox "Nom du système de fichier : " & strFileSystemName
Else
MsgBox "Une erreur s'est produite !", vbExclamation
End If
End Sub |
Partager