Key Generator based on HDD serial number

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
 
J

Jason

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top