Get the volume serial number of a drive
This code returns the volume serial for a hard drive (VB6).

Code

Public Declare Function GetVolumeSerialNumber Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As Long, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As Long, ByVal nFileSystemNameSize As Long) As Long

Public Function VolumeSerial(DriveLetter) As Long
Dim Serial As Long
Call GetVolumeSerialNumber(UCase(DriveLetter) & ":\", 0&, 0&, Serial, 0&, 0&, 0&, 0&)
VolumeSerial = Serial
End Function


Example Usage
MsgBox VolumeSerial("C")

Read the complete post at http://alexrazon.blogspot.com/2006/11/get-volume-serial-number-of-drive.html

Published 11-15-2006 3:42 PM by Alexis' Blog
Filed under: ,