There are some ways to get the serial number of a hard drive. I've searched and designed code like this:
Public Function GetDriveSerialNumber() As String
Dim DriveSerial As Long
Dim fso As Object, Drv As Object
fso = CreateObject("Scripting.FileSystemObject")
Drv = fso.GetDrive(fso.GetDriveName("C:\"))
With Drv
If .IsReady Then
DriveSerial = .SerialNumber
Else
DriveSerial = -1
End If
End With
Drv = Nothing
fso = Nothing
GetDriveSerialNumber = Hex(DriveSerial)
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
MsgBox(GetDriveSerialNumber(), vbOKOnly, "Serial")
End Sub
Within the Stack Overflow site, there are many code blocks like that. When I run the code it gives me my hard drive C's serial number like "349B3214".
I haven't tried to format my computer, but does it change after formatting? I mean when I run, it says your serial is "349B3214". If I format my computer and run this code again, does it gives me the same serial or different?