Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
1. How will I assign a License Key to my software before I distribute?
2. I want each installation to have a unique key per PC.
Posted
Comments
Dalek Dave 9-Sep-10 7:31am    
I edited the BIG tags out.
BIG will not make people answer quicker, and makes it harder to read.
ammor_ad 15-Jul-11 1:47am    
how it will be decoded later??? will u plz help?

There are a lot of articles on CP[^] that could point you in the right direction.

This article [^] helped me when I was looking for a unique value. It discusses pulling info about a computer with WMI. I use it to pull a ComputerSystemProduct UUID which so far appears to be unique for each computer (no guarantees). These are the methods I used to pull it:

VB
''' <summary>
   ''' Uses WMI to find all ComputerSystemProduct UUIDs and returns them (concatenated) in a string.
   ''' In testing, this value appears to be unique for each machine.
   ''' </summary>
   ''' <returns></returns>
   ''' <remarks></remarks>
   Private Function GetComputerSystemProductUUID() As String
       Return GetManagementObject("UUID", "Win32_ComputerSystemProduct")
   End Function

   ''' <summary>
   ''' Uses WMI to pull properties (specified by the strPropery parm) from collections of management objects
   ''' and returns a concatenated string of all properties from all collections found on the machine.
   ''' </summary>
   ''' <param name="strProperty"></param>
   ''' <param name="strCollection"></param>
   ''' <returns></returns>
   ''' <remarks></remarks>
   Private Function GetManagementObject(ByVal strProperty As String, ByVal strCollection As String) As String
       Dim sb As New System.Text.StringBuilder
       Try
           'Use a ManagementObjectSearcher object to select a property from a collection
           Dim objSearcher As New ManagementObjectSearcher("SELECT " & strProperty & " FROM " & strCollection)
           Dim objCollection As ManagementObjectCollection = objSearcher.Get
           For Each objM As ManagementObject In objCollection
               For Each objP As PropertyData In objM.Properties
                   If objP.Value IsNot DBNull.Value Then
                       sb.Append(objP.Value) 'Concats together if there are multiple collections or properties
                   End If
               Next
           Next
           'Clean up objects
           objSearcher.Dispose()
           objCollection.Dispose()
       Catch ex As Exception
           MsgBox(ex.Message)
       End Try

       Return sb.ToString
   End Function


Hope this helps.
 
Share this answer
 
Comments
RaviRanjanKr 11-Nov-11 15:46pm    
Nice Answer, My 5+
There are different ways to achieve this
1) encrypted license files that contains the expiry dates etc.
2) encrypted license keys held in the registry
3) challenge/response mechanism which require an internet connection
4) probably others.......
Try: License Key Generation[^] or: How can I create a Product Key for my C# App[^] or: c# Licensing[^]
Couple of them are in C# which can be seen to start on VB
Also,
Cryptography 101 for the .NET Framework[^]
Hope this helps.
 
Share this answer
 
If you wish to prevent users re-distributing the software to others, license key as such is of no use. Only way is to generate a code on users machine which is decoded by you and sent to him by mail or other means. (same is done by on line product activation). If it is to be done offline then what I mentioned above is the only answer. I have developed it and it works.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900