views:

1260

answers:

4

I want to get the VB.NET or VB code to access the hard disk serial no when starting the program. It's to help me to protect my own software from people who try to pirate copies.

+2  A: 

People often need to upgrade/replace their hard disk. Better to use the serial number from the DMI.

pixelbeat
+3  A: 

I can't offer you the code, sorry, but instead I provide a warning based on my previous experience in the area.

The "Hard Disk Serial No" that was used by a number of licensing systems is actually a soft number that is written on the disk, not hardwired into the hardware.

Enterprises that used "ghosting" software to quickly churn out many desktop machines, or virtualisation software to quickly churn out many servers often had identical Hard Drive identification.

So beware if your goal is to prevent enterprises from buying one copy and using it (perhaps unintentionally) on many machines.

Oddthinking
+2  A: 

This question is almost the same.

Eduardo Campañó
+6  A: 

In c#, but you get the idea. You'll want to use System.Management for this:

string driveLetter = Environment.SystemDirectory.Substring(0, 2);
string sn = new System.Management.ManagementObject("Win32_LogicalDisk.DeviceID=\"" + driveLetter + "\"").GetPropertyValue("VolumeSerialNumber").ToString();

As others have pointed out, this might not be the best way to handle this. However, that's your business.

Jon B