CPU or HD Serial

G

Gianmaria

Anyone knows how can i get the cpu serial or the hd serial of the machine
runnig the application with c#?


regards
Gianmaria
 
N

Nicholas Paldino [.NET/C# MVP]

Gianmaria,

You should use the classes in the System.Management namespace to run a
WMI query on the system. There is one instance of the Win32_Processor class
for each processor on a machine. You should be able to use the DeviceID
property here to get the unique id of the processor. For the hard drives,
you should be able to get all instances of the Win32_DiskDrive class and
then use the DeviceID property on that class.

Hope this helps.
 
D

Diwakar R

I guess you could find it out from HKLM/Hardware in the registry...

You could use Microsoft.Win32 namespace - RegistryKey class.

Hope this helps.

-Diwakar
 
A

Alek Davis

Gianmaria,

You must be aware that not all CPUs have serial numbers available (remeber a
huge controversy over Intel decision to enable CPU serial numbers a couple
of yers ago?).

This is how you can get CPU serial number (or numbers in case it is a
multi-CPU machine):

using System;
using System.Management;
....
SelectQuery query = new SelectQuery("Win32_BaseBoard");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection coll = searcher.Get();

foreach (ManagementObject obj in coll)
Console.WriteLine("Win32_BaseBoard: SerialNumber = " +
obj.Properties["SerialNumber"].Value);

You can use a similar approach to get the serial number of a hard drive.

Alek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top