Link to home
Start Free TrialLog in
Avatar of kyleboca
kyleboca

asked on

C# Precanned code for licensing

I am completing a project and would like to allow it to run only on a licensed machine. Can anyone recommend a method to generate a code that would require a key to unlock the software and not allow it to be installed on another machine? Is there a Class that I can just add to my project that will do this?

Thanks in advance for your help.
Avatar of mokule
mokule
Flag of Poland image

Verify this
http://www.infralution.com/licensing.html

regards
mokule
Avatar of kyleboca
kyleboca

ASKER

That looks like just what I need but the price is too high for this application.

Any other ideas?
Take end user’s machine’s MAC address and create a serial number for that MAC address and compare MAC address and serial number when the application runs. This will create a machine specific license. One key will not work on another machine. You can take any hardware id of the client machine e.g.. Processor Number, Volume Serial No, etc.…

Following is a code which is fetching MAC address.

Imports System.Management

Public sub GetMACAddress()

	Dim objMOS As ManagementObjectSearcher
	Dim objMOC As Management.ManagementObjectCollection
	Dim objMO As Management.ManagementObject
	
	objMOS = New ManagementObjectSearcher("Select * From Win32_NetworkAdapter")
	objMOC = objMOS.Get
	
	For Each objMO In objMOC
		MessageBox.Show(objMO("MACAddress"))
	Next
	
	objMOS.Dispose()
	objMOS = Nothing
	objMO.Dispose()
	objMO = Nothing
	
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will look into these possible solutions today.

Can you recommend something specific to the C# language? I have zero VB experience.
the downloadable demo solution contains both VB and C# projects.
This is C# code
public void GetMACAddress()
{
    
    ManagementObjectSearcher objMOS = default(ManagementObjectSearcher);
    Management.ManagementObjectCollection objMOC = default(Management.ManagementObjectCollection);
    Management.ManagementObject objMO = default(Management.ManagementObject);
    
    objMOS = new ManagementObjectSearcher("Select * From Win32_NetworkAdapter");
    objMOC = objMOS.Get;
    
    foreach (var objMO in objMOC) {
        MessageBox.Show(objMO("MACAddress"));
    }
    
    objMOS.Dispose();
    objMOS = null;
    objMO.Dispose();
        
    objMO = null;
}

Open in new window

This looks good. I will give it a try.