CPU or HD Serial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gianmaria

    #1

    CPU or HD Serial

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


    regards
    Gianmaria


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: CPU or HD Serial

    Gianmaria,

    You should use the classes in the System.Manageme nt 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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Gianmaria" <noSpamGianmari a@telenet.it> wrote in message
    news:ekUUnFJnDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Anyone knows how can i get the cpu serial or the hd serial of the machine
    > runnig the application with c#?
    >
    >
    > regards
    > Gianmaria
    >
    >[/color]


    Comment

    • Diwakar R

      #3
      Re: CPU or HD Serial

      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
      "Gianmaria" <noSpamGianmari a@telenet.it> wrote in message
      news:ekUUnFJnDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Anyone knows how can i get the cpu serial or the hd serial of the machine
      > runnig the application with c#?
      >
      >
      > regards
      > Gianmaria
      >
      >[/color]


      Comment

      • Alek Davis

        #4
        Re: CPU or HD Serial

        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.Manageme nt;
        ....
        SelectQuery query = new SelectQuery("Wi n32_BaseBoard") ;
        ManagementObjec tSearcher searcher = new ManagementObjec tSearcher(query );
        ManagementObjec tCollection coll = searcher.Get();

        foreach (ManagementObje ct obj in coll)
        Console.WriteLi ne("Win32_BaseB oard: SerialNumber = " +
        obj.Properties["SerialNumb er"].Value);

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

        Alek

        "Gianmaria" <noSpamGianmari a@telenet.it> wrote in message
        news:ekUUnFJnDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Anyone knows how can i get the cpu serial or the hd serial of the machine
        > runnig the application with c#?
        >
        >
        > regards
        > Gianmaria
        >
        >[/color]


        Comment

        Working...