June 15, 2024

Network System

Une technologie unique

Distinctive Components ID in C#

2 min read

Any personal computer has parts that have a precise serial quantity. Some figures are assigned when the operating method is mounted, but some are really embedded in the components. Using C#, a number of embedded serials can be blended to produce a special pc ID.

Why a unique serial? A uncomplicated explanation is for branding software package to a distinct laptop or computer. A most likely rigid licensing process, it can be fairly powerful relying on how it is used.

For this write-up we will use two serials, the difficult generate and the CPU. Equally will be obtained with the built-in C# course Process.Administration.

If you create a New Project in Visible Studio 2005 (any of the editions), you will observe the line “making use of Program.Administration” does not perform. You have to include it manually:

  • Go to the Alternative Explorer
  • Proper-click on References and click on “Incorporate Reference…”
  • Uncover System.Administration from the .Internet tab.

As soon as established up it is quick to get the components ID’s.

The difficult drive ID’s is dependent certainly on the harddrive. In this article is the pseudocode:

  • Build a ManagementObject with the string “acquire32_logicaldisk.deviceid=[drive letter here]:”
  • Access the serial with the index “VolumeSerialNumber”, for illustration disk[“VolumeSerialNumber”] wherever disk is the ManagementObject

The CPU ID is basically instead flexible also. Lots of computer systems today have a lot more than a single CPU. You use the to start with one particular as in my instance, or a number of ones:

  • Generate a ManagementObject with the string “acquire32_processor”
  • Go by the accessible processors
  • Access the assets like so: managObject.Qualities[“processorID”]

Combining them can be very simple or advanced. Basically including them together in a row functions just fine. For my illustration some redundant 0’s are taken out prior to coming the ID’s of the initially accessible push and the to start with CPU.

Test it out to see how the quantities look.

Leave a Reply