Questo è il codice, dovrebbe funzionare, devo testarlo anche io, anzi facciamo così visto che ancora devo finire il mio, fammi sapere se funziona. Cmq ad occhio e croce mi sembra funzioni.
Imports System
Imports System.Text
Imports System.Runtime.InteropServices
Public NotInheritable Class Win32Wrapper
Public const DRIVE_UNKNOWN = &H0
Public const DRIVE_NO_ROOT_DIR = &H1
Public const DRIVE_REMOVABLE = &H2
Public const DRIVE_FIXED = &H3
Public const DRIVE_REMOTE = &H4
Public const DRIVE_CDROM = &H5
Public const DRIVE_RAMDISK = &H6
<DllImport("kernel32.dll")> _
Public Shared Function GetDriveType(ByVal lpRootPathName As String) As System.UInt32
End Function
<DllImport("kernel32.dll")> _
Private Shared Function GetVolumeInformation(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As StringBuilder, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Integer, ByRef lpMaximumComponentLength As Integer, ByRef lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As StringBuilder, ByVal nFileSystemNameSize As Integer) As Boolean
End Function
Public Shared Function GetVolumeName(ByVal strRootPath As String) As String
Dim sbVolumeName As StringBuilder = New StringBuilder(256)
Dim sbFileSystemName As StringBuilder = New StringBuilder(256)
Dim nVolSerial As Integer = 0
Dim nMaxCompLength As Integer = 0
Dim nFSFlags As Integer = 0
Dim bResult As Boolean = GetVolumeInformation(strRootPath, sbVolumeName, 256, nVolSerial, nMaxCompLength, nFSFlags, sbFileSystemName, 256)
If bResult Then
Return sbVolumeName.ToString
Else
Return ""
End If
End Function
Public Shared Function GetInformations(ByVal strRootPath As String) As String()
Dim sbVolumeName As StringBuilder = New StringBuilder(256)
Dim sbFileSystemName As StringBuilder = New StringBuilder(256)
Dim nVolSerial As Integer = 0
Dim nMaxCompLength As Integer = 0
Dim nFSFlags As Integer = 0
Dim result As String() = {"", "", "", "", ""}
Dim bResult As Boolean = GetVolumeInformation(strRootPath, sbVolumeName, 256, nVolSerial, nMaxCompLength, nFSFlags, sbFileSystemName, 256)
If bResult Then
result(0) = sbVolumeName.ToString
result(1) = sbFileSystemName.ToString
result(2) = nVolSerial.ToString
result(3) = nMaxCompLength.ToString
result(4) = nFSFlags.ToString
End If
Return result
End Function
End Class
---------------------
Domani andrà meglio