La procedura riportata non funziona perchè mancano delle dichiarazioni di variabile. Prova questa:
codice:
'dichiarazione API
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
'in una procedura
Dim ret As Long 'valore di ritorno
Dim vnb As String * 50 'buffer per Volume Name
Dim vsn As Long 'Volume Serial Number
Dim mcl As Long 'Maximum Component Length
Dim fsf As Long 'File System Flags
Dim fsnb As String * 10 'buffer per File System Name
ret = GetVolumeInformation("C:\", vnb, Len(vnb), vsn, mcl, fsf, fsnb, Len(fsnb))
If ret <> 0 Then
Debug.Print "Volume Name : " & vnb
Debug.Print "Volume Serial Number : " & vsn
Debug.Print "Maximum Component Length : " & mcl
Debug.Print "File System Flags : " & fsf
Debug.Print "File System Name : " & fsnb
End If
Spesso il numero seriale viene espresso in esadecimale: basta usare la funzione Hex$()