This is Remedy's answered
remedy (Programmer) Jul 27, 2001
It's easy using FileSystemObject:
Private Function GetSerialNum(ByVal DriveName As String) As Long
Dim loFSO As FileSystemObject
Dim loDrive As Drive
Set loFSO = New FileSystemObject
Set loDrive = loFSO.GetDrive(DriveName)
If loDrive.IsReady Then
GetSerialNum = loDrive.SerialNumber
Else
GetSerialNum = 0
End If
Set loFSO = Nothing
End Function
Private Declare Function GetVolumeInformation Lib "kernel32.dll" 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
Or otherwise you can us API:
(in that case you can get even more information as you can see)
Private Function GetSerialNum(DriveName As String) As Long
Dim lsVolumeName As String
Dim liSerialNum As Long
Dim lsSerNumStr As String
Dim liMaxCompLength As Long
Dim liFileSysFlags As Long
Dim lsFileSysName As String
Dim liRetval As Long
lsVolumeName = Space$(256)
lsFileSysName = Space$(256)
liRetval = GetVolumeInformation(DriveName, lsVolumeName, 256, liSerialNum, liMaxCompLength, liFileSysFlags, lsFileSysName, 256)
GetSerialNum = liSerialNum
End Function
Remedy