Get the computer Id

I want to get computer id that always be uniqe even if windows of that computer have been changed.

please tell me how and where I can find something like this.

Code sample is helpfull too.



Answer this question

Get the computer Id

  • Lord Arokh

    well what happens when it doesnt work

  • chrisryche

    It doesn't compile and the error screen shows. Is there anything I need to do prior to your code

    Eragon.



  • Adrian Foot

    where can i find my computer id


  • Jakein2006

    so you are after a way to find a uniqueness of the computer it self This then has nothing to do with Windows. you have to find another way. This could be as posted, by looking at the SerialNumber of a harddisk or getting the Processor ID using WMI.

    add a reference to System.Management.dll

    then to get the processorID (CPUID) you can do this for example:

     



    System.Management.ManagementClass theClass = new System.Management.ManagementClass("Win32_Processor");
    System.Management.ManagementObjectCollection theCollectionOfResults = theClass.GetInstances();
     
    foreach(System.Management.ManagementObject currentResult in theCollectionOfResults)
    {
       MessageBox.Show(currentResult["ProcessorID"].ToString());
    }
     

     



  • hye_heena

    the computerID is the computername which Windows Sets - this will always be unique on the computer and the network its connected to

    you can get the computerName:

    Environment.MachineName;

    is this what you are after



  • Mark The Archer Evans

    You need a way of retrieving hard disk Volume ID. I know that when i need such thing i did with api function. There are many articles that shows how to do it. Here is link http://www.eggheadcafe.com/articles/20021019.asp that i find in 10 seconds. This is used very offen for creating better security of your application instalation, because it will work only on that hard drive.



  • Thomas Wolfram

    which computer ID are you talking about The computer name if so, as stated earlier:

    Environment.MachineName;



  • chubbysilk

    hi,

    sorry for marking it non- helpful, but it didn't work for me, it showed all these errors. Is there something I need to do before coding what you wrote this was for the code you first wrote about processors and motherboards etc.

    Thanks & Sorry.

    Eragon.



  • Rooster A.

    There are a lot of things to get a strong unique ID of computer like, CPU Serial Number, Mother Board Serial Number, Hard Disk Serial Number, MAC Address and OS Version.

    These things are usually for some strong licensing:

    http://www.codeproject.com/useritems/Trial_Maker.asp

    This article include ways to get CPU and Main Board Serial Numbers, There are also other examples easily available on internet to get Hard Disk Serial, MAC Address and OS version.

    Best of Luck ;-)



  • Harkernator

    no it wont - each CPU has a unique Product ID/Identifier.

    Have you actually tried it



  • sud

    hi,

    this following piece of code that you wrote earlier didn't work:

    System.Management.ManagementClass theClass = new System.Management.ManagementClass("Win32_Processor");
    System.Management.ManagementObjectCollection theCollectionOfResults = theClass.GetInstances();

    foreach(System.Management.ManagementObject currentResult in theCollectionOfResults)
    {
    MessageBox.Show(currentResult["ProcessorID"].ToString());
    }

    How do you work that

    Thanks.

    Eragon.



  • Ofir Epstein

    Thanks for your attention but the computer name will be changed.either the user or changng windows can change that.I know that the computer must have a something like mashine name....

    this is what i need


  • Roozbeh Sharafi

    I have implemented the similar approach, which operates with hardware ids. It was constructing a string like "Processor1_ID=XXX,Processor2_ID=YYY,...,Primary_HD=ZZZ,...NIC1_MAC=...".
    Here is the painful experience:
    • Desktops and servers are usually OK. Use combination of CPU ids and primary hard drive id. Laptops are pain in the butt, as people plug their laptops whereever they want and use hotswap hardeware, therefore some customers report expired licenses.
    • MAC addresses are BAD because connecting to VPNs or wireless networks or disabling-enabling adapters can change the number or order of network adapters. Your ID will be changing with every single USB or PCMCA NIC plugged in, or when user connects to VPN via Cisco or Nortel clients (they create virtual adapters).
    • Drive Volume IDs and motherboard IDs misbehave with docking stations and some Thinkpads. We were unable to identify the pattern.
    We usually observed some customers to have 2 system IDs changing back and forth. At this moment we have three independent approaches towards software licensing:
    • USB dongle. Works 100% good, guarantees 1 use at a time. Adds some $$$ to the product price, which we normally can live with; Does not fit for domain-type licenses, where you have as many users as customers want;
    • WebLease(tm) technology (one of things we are planning to promote on the market) - program asks for confirmation from web server before calling a function. This requires internet connection, but allows pay-as-you-go type of service, monthly fees etc;
    • Weighted method: you have some processor IDS, some hard drive IDS, some MAC addresses, windows registration code, etc in a text file. Your program reads current system values and looks up these lists. If it fails to find at least 2 matching parameters, it fails (and customer has to request updated license file from you).
    It could make things way easier if Windows could have an unique key code per install...

  • Patrick Ma

    that's also will return the same result for the same proccessor. I have several computer in our company and result was the same in some of them
  • Get the computer Id