Any computer has parts that carry a distinct serial variety. Some figures are assigned when the functioning method is mounted, but some are essentially embedded in the hardware. Applying C#, several embedded serials can be merged to generate a exceptional computer ID.
Why a exclusive serial? A uncomplicated rationale is for branding software program to a unique computer system. A most likely rigid licensing program, it can be pretty effective based on how it is employed.
For this write-up we will use two serials, the challenging drive and the CPU. Both will be acquired with the designed-in C# class Technique.Management.
If you build a New Challenge in Visual Studio 2005 (any of the editions), you will notice the line “utilizing Program.Administration” does not operate. You have to incorporate it manually:
- Go to the Resolution Explorer
- Proper-simply click on References and simply click “Insert Reference…”
- Find Procedure.Administration from the .Web tab.
The moment established up it is easy to get the components ID’s.
The hard travel ID’s depends certainly on the harddrive. Listed here is the pseudocode:
- Create a ManagementObject with the string “gain32_logicaldisk.deviceid=[drive letter here]:”
- Entry the serial with the index “VolumeSerialNumber”, for example disk[“VolumeSerialNumber”] the place disk is the ManagementObject
The CPU ID is basically rather flexible also. A lot of personal computers these days have extra than one particular CPU. You use the initial 1 as in my instance, or a number of ones:
- Generate a ManagementObject with the string “acquire32_processor”
- Go as a result of the offered processors
- Entry the home like so: managObject.Properties[“processorID”]
Combining them can be basic or sophisticated. Merely introducing them with each other in a row works just fantastic. For my case in point some redundant 0’s are removed just before coming the ID’s of the first out there travel and the initially CPU.
Consider it out to see how the quantities glimpse.
