Key Generator based on HDD serial number

  • Thread starter Thread starter Dante
  • Start date Start date
D

Dante

Hi

I want to do a key generator based on the local computer hard drive
serial number. My problem is on getting the hard drive serial number.
I found many examples like the one below, but this code gets the
hardrive with "c:" id, so it will not work if the computer doesnt have
a drive with the id of "c:". My question is, how do i know all the
hardrives id on the local computer? Does anyone knows a better method
to do this?

(This is the code I am currently using to get the hard drive serial
number)

Dim disk As New ManagementObject("Win32_LogicalDisk.DeviceID=""C:""")
Dim diskProperty As PropertyData

For Each diskProperty In disk.Properties
Console.WriteLine("{0} = {1}", diskProperty.Name,
diskProperty.Value)
Next diskProperty

Thanks in advance
Dante
 
ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from
Win32_LogicalDisk");
ManagementObjectCollection moc = mos.Get();

foreach(ManagementObject disk in moc)
Console.WriteLine("{0} = {1}", disk["DeviceID"],
disk["VolumeSerialNumber"]);

Enjoy

Jason
 
Back
Top