One of the techniques used when you plan to protect your valuable intellectual property 🙂 (your code) is reading some kind of hardware signature of machine where program is installed.
Usual initial approach is to read Volume serial number (bear in mind that this number can be easily changed) or similar hardware information. Here is where WMI – Windows Management Instrumentation comes in play – you can find enormous amount of information using WMI.
Let’s give small example – find out Volume Serial Number:
– add reference to System.Management.dll
– here is the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace Org.Vesic.WMI.Example
{
class Program
{
static void Main(string[] args)
{
string targetVolume = "C";
if((args != null) && args.Length > 0)
{
targetVolume = args[0];
}
string mngObject = String.Format("Win32_LogicalDisk.DeviceID="{0}:"",
targetVolume);
try
{
ManagementObject myDisk = new ManagementObject(mngObject);
PropertyData myDiskProp = myDisk.Properties["VolumeSerialNumber"];
Console.WriteLine("HDD Serial for Volume {0}: is {1}",
targetVolume, myDiskProp.Value);
}
catch(ManagementException ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Simple and very effective. Of course, you can read load of other data types, NIC info, even CPU info:
ManagementObjectSearcher mos = new ManagementObjectSearcher
("SELECT Name, L2CacheSize, L2CacheSpeed FROM Win32_Processor");
ManagementObjectCollection moc = mos.Get();
int procCount = -1;
foreach (ManagementObject mob in moc)
{
procCount++;
Console.WriteLine("Processor No. {0}: {1}, L2 Cache size/speed: {2} / {3}",
procCount,
mob.Properties["Name"].Value,
mob.Properties["L2CacheSize"].Value,
mob.Properties["L2CacheSpeed"].Value
);
}




Utility with very suggestive name 😉 was created when I found out (by slow trial and error method) that my stupid DVD player Marantz DV 4100 (picture), brilliant in all other areas, won’t play burned DVD disks if those disks are not filled up to the end, all 4.7GB – it seems that it dislikes color of not burned part of the disk.
Recently, I became owner of the nice, heavy and elegant phone, 


