DiskSerialNumber




Private Declare Function GetVolumeInformation Lib "kernel32.dll" _
Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal _
lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), _
SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function

'Use

'An example of using the above function:

Call MsgBox GetSerialNumber("C:\")
'This will bring up a message box with the serial number of

'the C drive.











( diskserialnumber.html )- by Paolo Puglisi - Modifica del 17/12/2023