CodeItBetter Programming Another VB Programming Blog

How to Get Floppy/CD/Hard Drive 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
22
'File/Folder Handling - How to Get Floppy/CD/Hard Drive Serial Number

Option Explicit
 
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, res As Long
    Dim Temp1 As String, 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
 
'How can I call this function:
Private Sub Command1_Click()
    Call MsgBox(GetSerialNumber("C:\"))
End Sub

Related posts:

  1. How to Return a volume’s serial number
  2. How to check whether CD/Floppy Disk is in the Drive
  3. How to get the USB’s Serial Number
  4. How to get Volume label, Serial Number and File system of a given drive name
  5. How to Return Volume Name for given Drive letter
  6. How to check whether the file system is FAT 32 or NTFS
  7. How to get free disk space of C drive (in two ways)
  8. How to Format Floppy Disk
  9. How to find Mother boad Serial Number
  10. How to find whether the given directory is empty (in three ways)

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.