ZeroEffect
Junior Contributor
I have found a couple of ways to get a serial number for a hard drive. One way is like this
That works great but the serial number would change if the drive is reformated. The other way is like this
This works great because it returns the physical HD serial number but I can't tell which drive is the "C" drive if there is more than one drive.
I want to use the Physical HD serial number and hash it to make an activation password for my application. Is there a way to do this?
Thanks
ZeroEffect
Visual Basic:
Dim fso As Scripting.FileSystemObject
fso = New Scripting.FileSystemObject()
TextBox1.Text = Hex(fso.GetDrive("C").SerialNumber())
That works great but the serial number would change if the drive is reformated. The other way is like this
Visual Basic:
TextBox1.AppendText(vbCrLf)
Dim hdCollection As New ArrayList()
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim wmi_HD As New ManagementObject()
For Each wmi_HD In searcher.Get
Dim hd As New HardDrive()
hd.Model = wmi_HD("Model").ToString()
hd.Type = wmi_HD("InterfaceType").ToString()
hdCollection.Add(hd)
Next
Dim searcher1 As New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
Dim i As Integer = 0
For Each wmi_HD In searcher1.Get()
'// get the hard drive from collection
'// using index
Dim hd As HardDrive
hd = hdCollection(i)
'// get the hardware serial no.
If wmi_HD("SerialNumber") = "" Then
hd.serialNo = "None"
Else
hd.serialNo = wmi_HD("SerialNumber").ToString()
i += 1
End If
Next
Dim hd1 As HardDrive
Dim ii As Integer = 0
For Each hd1 In hdCollection
ii += 1
TextBox1.Text = TextBox1.Text + "Disco Name: " + hd1.name + Chr(13) + Chr(10)
TextBox1.Text = TextBox1.Text + "Disco #: " + ii.ToString + Chr(13) + Chr(10)
TextBox1.Text = TextBox1.Text + "Model: " + hd1.Model + Chr(13) + Chr(10)
TextBox1.Text = TextBox1.Text + "Tipo: " + hd1.Type + Chr(13) + Chr(10)
TextBox1.Text = TextBox1.Text + "Serial No: " + hd1.serialNo + Chr(13) + Chr(10) + Chr(13) + Chr(10)
Next
This works great because it returns the physical HD serial number but I can't tell which drive is the "C" drive if there is more than one drive.
I want to use the Physical HD serial number and hash it to make an activation password for my application. Is there a way to do this?
Thanks
ZeroEffect
Last edited: