CodeItBetter Programming Another VB Programming Blog

How to get the USB’s Serial Number

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'System & API - How to get the USB's Serial Number
Option Explicit
 
Private Declare Function GetVolumeInformation Lib "kernel32" 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
 
Private Const MAX_BUFFER As Long = 256
 
Public Function GetVolSerNo(ByVal sDrive As String) As String
    Dim sVolumeName As String * 256
    Dim sFileSystem As String * 256
    Dim lSerNo As Long
 
    If GetVolumeInformation(sDrive, sVolumeName, MAX_BUFFER, lSerNo, 0, 0, _
        sFileSystem, MAX_BUFFER) Then
        GetVolSerNo = Hex$(lSerNo)
    End If
End Function
 
Sub Main()
    Debug.Print GetVolSerNo("D:\")
End Sub

Related posts:

  1. How to check whether the file system is FAT 32 or NTFS
  2. How to get Volume label, Serial Number and File system of a given drive name
  3. How to Return a volume’s serial number
  4. How to Get Floppy/CD/Hard Drive Serial Number
  5. How to get User’s local information
  6. How to Return Volume Name for given Drive letter
  7. How to check whether CD/Floppy Disk is in the Drive
  8. How to find Mother boad Serial Number
  9. How to Enumerate the user accounts on your system / network
  10. How can i get the mouse to automatically click???? Like on its own.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.