One of a kind Components ID in C#

One of a kind Components ID in C#

Any computer system has components that have a specific serial variety. Some quantities are assigned when the functioning method is put in, but some are actually embedded in the components. Utilizing C#, a number of embedded serials can be merged to build a exclusive pc ID.

Why a distinctive serial? A straightforward motive is for branding application to a specific laptop. A possibly inflexible licensing system, it can be really productive relying on how it is utilized.

For this write-up we will use two serials, the tough generate and the CPU. Both equally will be attained with the developed-in C# class Program.Management.

If you create a New Challenge in Visible Studio 2005 (any of the editions), you will discover the line “making use of System.Management” does not work. You have to include it manually:

  • Go to the Option Explorer
  • Proper-simply click on References and click on “Insert Reference…”
  • Find Process.Administration from the .Internet tab.

When set up it is simple to get the hardware ID’s.

The tough drive ID’s depends clearly on the harddrive. Listed here is the pseudocode:

  • Make a ManagementObject with the string “win32_logicaldisk.deviceid=[drive letter here]:”
  • Accessibility the serial with the index “VolumeSerialNumber”, for illustration disk[“VolumeSerialNumber”] exactly where disk is the ManagementObject

The CPU ID is in fact rather adaptable also. Numerous pcs nowadays have much more than one particular CPU. You use the initial 1 as in my example, or multiple kinds:

  • Develop a ManagementObject with the string “acquire32_processor”
  • Go by means of the available processors
  • Accessibility the assets like so: managObject.Properties[“processorID”]

Combining them can be uncomplicated or intricate. Merely incorporating them alongside one another in a row operates just good. For my instance some redundant 0’s are removed just before coming the ID’s of the 1st obtainable drive and the initially CPU.

Try out it out to see how the quantities seem.