C# Precanned code for licensing

kyleboca
kyleboca used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

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

regards
mokule

Author

Commented:
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

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Senior .Net Consultant
Top Expert 2016
Commented:

Author

Commented:
I will look into these possible solutions today.

Can you recommend something specific to the C# language? I have zero VB experience.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
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

Author

Commented:
This looks good. I will give it a try.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial