Unique Hardware ID in C #

Each computer is equipped with components that have a specific serial number. Some numbers are assigned when the operating system is installed, but some are actually built into the hardware. With C # can more embedded series are combined to create a unique ID of the computer.

Why a unique serial number? A simple reason for the branding software for a particular computer. A licensing system may be inflexible, can be very effective, depending on how it is used.

For this article, there are twoSeries, the hard drive and CPU. Both are obtained with the built-in C # Class System.Management.

When you create a new project in Visual Studio 2005 (one of the editions), you see the line "using System.Management" warning does not work. You must manually add:


Go to Explorer


Right-click References and click on "Add Reference ..."


Find System.Management card. NET.

Once set up is easy to reachHardware ID.

The record ID of course depends on the hard disk. Here is the pseudo code:


Create a management object with the string "win32_logicaldisk.deviceid = [drive letter here]"


Call serial number with the "serial number of the book" index, for example disk ["volume serial number"], in which disc is the subject of management

The CPU ID is actually very flexible, too. Most computers today have more than one CPU. Use the first, as in my example, or morethose:


Create a management object with the string "Win32"


Go through the available processors


Call the property in this way: managObject.Properties ["processorID"]

Compounds can be simple or complex. It works just fine together in a row. For my example, some redundant 0 are removed before the first hard disk ID and the first available CPU.

Try it and see what those numbers.

federal loan

0 Response to "Unique Hardware ID in C #"

Post a Comment

Powered by Blogger