Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Serial number of drive


'Declare
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



'example
MsgBox SerialNumber( "C" )

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