Click here to Skip to main content
Rate this: bad
good
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)];
               builder.Append(ch);
           }
           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
good
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...
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2014
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