Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaxComponentLentgh As Long, lpFileSysyemFlags As Long, ByVal lpFileSystemBuffername As String, ByVal nFileSystemNameSize As Long) As Long
Public sDrive As String
Public DriveSerial As String
Public Function GetSerialNumber(ByVal sDrive As String) As Long
If Len(sDrive) Then
If InStr(sDrive, "\\") = 1 Then
If Right$(sDrive, 1) <> "\" Then
sDrive = sDrive & "\"
End If
Else
sDrive = Left$(sDrive, 1) & ":\"
End If
Else
sDrive = vbNullString
End If
Call GetVolumeInformation(sDrive, vbNullString, 0, GetSerialNumber, ByVal 0&, _
ByVal 0&, vbNullString, 0)
End Function
Public Sub GetSerial()
DriveSerial = Hex$(GetSerialNumber(sDrive))
End Sub