tags:

views:

979

answers:

6

hi all I want to get unique unchangeable Machine id Like Processor serial number of the computer for distribute a software with out copying.I tried with processor serial number and hard disk serial number that all are changing after formatting and reinstalling the windows. Any idea how i can get an unchangeable serial number of a computer

please give me a solution

+2  A: 

edit: I just saw you meant in c#. Here is a better way with unmanaged code:

ManagementClass oMClass = new ManagementClass ("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection colMObj = oMCLass.GetInstances();
foreach(ManagementObject objMO in colMObj)
    Console.WriteLine(objMO["MacAddress"].ToString());
Blindy
You know that the MAC address is also "spoofable"?Besides, your code looks like C++, not like C#?
Webleeuw
Is there any solution plz suggest me
ush
Well if the processor/hdd serial numbers aren't sufficient, this is all you have left. If he described what he wanted to do instead of how he wants to do it, I might have had a better reply.
Blindy
+1  A: 

Check out this article. It is very exhaustive and you will find how to extract various hardware information.

Laurent Etiemble
+1  A: 

I second Blindy's suggestion to use the MAC address of the (first?) network adapter. Yes, the MAC address can be spoofed, but this has side effects (you don't want two PCs with the same MAC address in the same network), and it's something that "your average pirate" won't do just to be able to use your software. Considering that there's no 100% solution against software piracy, the MAC address is a good compromise, IMO.

Note, however, that the address will change when the user adds, replaces or removes a network card (or replaces his old PC altogether), so be prepared to help your customers and give them a new key when they change their hardware configuration.

Heinzi
+4  A: 

If you need a unique ID, you must first decide what do you mean with unique. If you like to use it for a copy protection mechanism than take something simple, cause if someone wants to use your software he can break your protection. In case of a unique hardware id, just think about VMware and you'll see you can spoof anything or someone can start to tamper your software.

So there is not much you can take from a pc as uniqueness over it's whole lifetime. If you need something like that you should start a search for a USB Dongle which you can send to your customers.

If you just need some less harder uniqueness you could take the MAC address, the OS serial number or the domain and username, but all of them are forgeable. But if your main goal is to lock out people you won't sell anything because no one wants to use your software because it is so hard to install or to move from one pc to another (this will happen quite often).

So in a first step, make it easy, take something simple which is not as easy to spoof in your target group (e.g. domain and usernames can't be good spoofed by enterprise customers, cause their pcs are running in a bigger environment with policies, etc.) and just forget about the others.

Maybe you can lock them out but that doesn't mean they're going to buy your software, they just don't use it anymore. But how many potential customers are not willing to pay cause you made it so complicated to use your program?

Oliver
A: 

I'd stay well away from use MAC addresses. On some hardware the MAC address can change when you reboot. We learned quite early during our research not to rely on it.

Take a look at the article Developing for Software Protection and Licensing which has some pointers on how to design & implement apps to reduce piracy.

Obligatory disclaimer & plug: the company I co-founded produces the OffByZero Cobalt licensing solution. So it probably won't surprise you to hear that I recommend outsourcing your licensing, & focusing on your core competencies.

Duncan Bayne
A: 

You can use WMI Code creator. I guess you can have a combination of "keys" (processorid,mac and software generated key).

using System.Management;
using System.Windows.Forms;

 try
            {
                ManagementObjectSearcher searcher = 
                    new ManagementObjectSearcher("root\\CIMV2", 
                    "SELECT * FROM Win32_Processor"); 

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Win32_Processor instance");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Architecture: {0}", queryObj["Architecture"]);
                    Console.WriteLine("Caption: {0}", queryObj["Caption"]);
                    Console.WriteLine("Family: {0}", queryObj["Family"]);
                    Console.WriteLine("ProcessorId: {0}", queryObj["ProcessorId"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
            }

Win32_Processor

Retrieving Hardware Identifiers in C# with WMI by Peter Bromberg

PRR