Distinctive {Hardware} ID in C#

Get ₹1000 welcome cash by signing-up on Pomento IT Companies

Any pc has parts that carry a selected serial quantity. Some numbers are assigned when the working system is put in, however some are literally embedded within the {hardware}. Utilizing C#, a number of embedded serials could be mixed to create a novel pc ID.

Why a novel serial? A easy purpose is for branding software program to a selected pc. A maybe rigid licensing system, it may be fairly efficient relying on how it’s employed.

For this text we’ll use two serials, the hard drive and the CPU. Each might be obtained with the built-in C# class System.Administration.

Should you create a New Undertaking in Visible Studio 2005 (any of the editions), you’ll discover the road “utilizing System.Administration” doesn’t work. It’s important to add it manually:

  • Go to the Answer Explorer
  • Proper-click on References and click on “Add reference…”
  • Discover System.Administration from the .Internet tab.

As soon as arrange it’s simple to get the {hardware} ID’s.

The hard drive ID’s relies upon clearly on the harddrive. Right here is the pseudocode:

  • Create a ManagementObject with the string “win32_logicaldisk.deviceid=[drive letter here]:”
  • Entry the serial with the index “VolumeSerialNumber”, for instance disk[“VolumeSerialNumber”] the place disk is the ManagementObject

The CPU ID is definitely fairly versatile additionally. Many computers these days have multiple CPU. You utilize the primary one as in my instance, or a number of ones:

  • Create a ManagementObject with the string “win32_processor”
  • Undergo the out there processors
  • Entry the property like so: managObject.Properties[“processorID”]

Combining them could be easy or complicated. Merely including them collectively in a row works simply superb. For my instance some redundant 0’s are eliminated earlier than coming the ID’s of the primary out there drive and the primary CPU.

Attempt it out to see how the numbers look.

Get ₹1000 welcome cash by signing-up on Pomento IT Companies

We will be happy to hear your thoughts

Leave a reply

Shopping cart