Click here to Skip to main content
11,438,226 members (58,618 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0 WinForm
hi to all,

how to generate the license key based on the MAC address of the Computer.

i have used the following code:
public string RandomString()
           string input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
           StringBuilder builder = new StringBuilder();
           char ch;
           for (int i = 0; i < 5; i++)
               ch = input[rd.Next(0, input.Length)];
           return builder.ToString();
private void btn_License_Click(object sender, EventArgs e)
            string s1 = RandomString();
            string s2 = RandomString();
            string s3 = RandomString();
            string s4 = RandomString();
            string s5 = RandomString();
            textBox1.Text = s1 + " - " + s2 + " - " + s3 + " - " + s4 + " - " + s5;
Posted 9-Jul-13 21:06pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That does nothing at all related to MAC addresses - it you want to use them, you will first have to retrieve it. This will help: Retrieving IP and MAC addresses for a LAN[^] - there is a method there to retrive the current PC MAC address.

But - don't waste too much time on this: MAC addresses can be spoofed, a PC will only have a MAC address if it has an active network connector, and most software protection methods annoy legitimate users more than they inconvenience pirates. You have to decide what level of piracy you are likely to get, how many of those can be converted into sales by protecting the software and the cost of the time to implement protection. Very often, it just isn't worth the effort...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150506.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100