CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2002
    Posts
    64

    Computer Unique ID?

    Hello everyone

    Is there any unique alpha numeric code that is used to identify each copy of windows or computer? If there is, then where it is stored. If it is in the registry, please provide the key location. Thanks for any help.

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Computer Unique ID?

    You can use MAC address of NIC of your computer. It must be unique, otherwise the computer cannot work on network. For inspiration how to obtain MAC address you can use following code:

    Code:
    using System;
    using System.Management;
    namespace WMI
    {
    	class Class1
    	{
    		static void Main(string[] args)
    		{
    			ManagementObjectSearcher query1;
    			ManagementObjectCollection queryCollection1;
    
    			query1 = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter") ;
    			queryCollection1 = query1.Get();
    			foreach( ManagementObject mo in queryCollection1 ) 
    			{
    				Console.Write(mo["caption"].ToString());
    				Console.Write(" MAC: ");
    				object mac = mo["MACAddress"];
    				if (mac != null) Console.Write(mac.ToString());
    				Console.WriteLine();
    			}
    		}
    	}
    }
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    May 2004
    Location
    Greenville, NC
    Posts
    193

    Re: Computer Unique ID?

    I don't know what you're intentions are, but maybe you can use System.Guid.NewGuid()

    http://msdn.microsoft.com/library/de...classtopic.asp

    I've never actually used it before, but according to most sources I read about GUID's, they usually use a combination of MAC Addresses, milliseconds since a particular time frame, and IP Addresses. However, that's irrelevant as the only important aspect of a GUID that is necessary to use one is that it's unique.

    You can do something like

    Code:
    Console.WriteLine("GUID : {0}", System.Guid.NewGuid());
    Although, this may or may not work for you. This will generate Unique Identifiers, but whether or not you're trying to generate UniqueIDs or are actually trying to find the UniqueIDs already assigned to a computer is two different stories.
    Jason Isom
    .NET 2.0 / VS2005 Developer

  4. #4
    Join Date
    May 2002
    Posts
    64

    Re: Computer Unique ID?

    Thanks for the help.

    I am trying to make my program running on one system only. It does not allow to run on multiple computers. I am still thinking of a solution

  5. #5
    Join Date
    Jun 2004
    Location
    New Jersey, USA
    Posts
    341

    Re: Computer Unique ID?

    Probably reading MAC address would be your solution. But beware that MAC address could be spoofed. You might want to read several identifiers like MAC, IP and make combination of it as unique PC identifier
    "We act as though comfort and luxury were the chief requirements of
    life, when all that we need to make us happy is something to be
    enthusiastic about."

    - Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured