├── Core ├── QLicense │ ├── QLicense.snk │ ├── LicenseStatus.cs │ ├── LicenseTypes.cs │ ├── BASE36.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── QLicense.csproj │ ├── LicenseEntity.cs │ ├── HardwareInfo.cs │ └── LicenseHandler.cs ├── ActivationControls4Win │ ├── ActivationControls4Win.snk │ ├── LicenseGeneratedEventArgs.cs │ ├── LicenseSettingsValidatingEventArgs.cs │ ├── LicenseStringContainer.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── LicenseInfoControl.Designer.cs │ ├── LicenseActivateControl.cs │ ├── LicenseSettingsControl.cs │ ├── LicenseStringContainer.Designer.cs │ ├── LicenseActivateControl.Designer.cs │ ├── LicenseInfoControl.cs │ ├── ActivationControls4Win.csproj │ ├── LicenseInfoControl.zh-Hans.resx │ ├── LicenseSettingsControl.Designer.cs │ ├── LicenseSettingsControl.zh-Hans.resx │ ├── LicenseStringContainer.zh-Hans.resx │ ├── LicenseActivateControl.zh-Hans.resx │ └── LicenseInfoControl.resx └── ActivationControls4Wpf │ ├── ActivationControls4Wpf.snk │ ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx │ ├── LicenseActivateControl.xaml │ ├── LicenseActivateControl.xaml.cs │ └── ActivationControls4Wpf.csproj ├── Docs └── High Level Process.vsdx ├── Demo ├── DemoWinFormApp │ ├── LicenseVerify.cer │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── App.config │ ├── Program.cs │ ├── frmActivation.cs │ ├── frmMain.Designer.cs │ ├── frmMain.cs │ ├── frmActivation.Designer.cs │ ├── DemoWinFormApp.csproj │ ├── frmMain.resx │ └── frmActivation.resx ├── DemoActivationTool │ ├── App.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── Program.cs │ ├── frmMain.cs │ ├── frmMain.Designer.cs │ ├── DemoActivationTool.csproj │ └── frmMain.resx └── DemoLicense │ ├── Properties │ └── AssemblyInfo.cs │ ├── MyLicense.cs │ └── DemoLicense.csproj ├── LICENSE.txt ├── .gitattributes ├── .gitignore └── QLicense.sln /Core/QLicense/QLicense.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soldierq/QLicense/HEAD/Core/QLicense/QLicense.snk -------------------------------------------------------------------------------- /Docs/High Level Process.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soldierq/QLicense/HEAD/Docs/High Level Process.vsdx -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/LicenseVerify.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soldierq/QLicense/HEAD/Demo/DemoWinFormApp/LicenseVerify.cer -------------------------------------------------------------------------------- /Core/ActivationControls4Win/ActivationControls4Win.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soldierq/QLicense/HEAD/Core/ActivationControls4Win/ActivationControls4Win.snk -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/ActivationControls4Wpf.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soldierq/QLicense/HEAD/Core/ActivationControls4Wpf/ActivationControls4Wpf.snk -------------------------------------------------------------------------------- /Core/QLicense/LicenseStatus.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense 2 | { 3 | public enum LicenseStatus 4 | { 5 | UNDEFINED = 0, 6 | VALID = 1, 7 | INVALID = 2, 8 | CRACKED = 4 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseGeneratedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense.Windows.Controls 2 | { 3 | public class LicenseGeneratedEventArgs 4 | { 5 | public string LicenseBASE64String { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseSettingsValidatingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QLicense.Windows.Controls 4 | { 5 | public class LicenseSettingsValidatingEventArgs:EventArgs 6 | { 7 | public LicenseEntity License { get; set; } 8 | public bool CancelGenerating { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/QLicense/LicenseTypes.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace QLicense 4 | { 5 | public enum LicenseTypes 6 | { 7 | [Description("Unknown")] 8 | Unknown = 0, 9 | [Description("Single")] 10 | Single = 1, 11 | [Description("Volume")] 12 | Volume = 2 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace DemoActivationTool 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main() 13 | { 14 | Application.EnableVisualStyles(); 15 | Application.SetCompatibleTextRenderingDefault(false); 16 | Application.Run(new frmMain()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace DemoWinFormApp 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new frmMain()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 TonyTonyQ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DemoWinFormApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DemoActivationTool.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ActivationControls4Wpf.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseStringContainer.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Windows.Forms; 3 | using System.IO; 4 | 5 | namespace QLicense.Windows.Controls 6 | { 7 | public partial class LicenseStringContainer : UserControl 8 | { 9 | public string LicenseString 10 | { 11 | get 12 | { 13 | return txtLicense.Text; 14 | } 15 | set 16 | { 17 | txtLicense.Text = value; 18 | } 19 | } 20 | 21 | public LicenseStringContainer() 22 | { 23 | InitializeComponent(); 24 | } 25 | 26 | private void lnkCopy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 27 | { 28 | if (!string.IsNullOrWhiteSpace(txtLicense.Text)) 29 | { 30 | Clipboard.SetText(txtLicense.Text); 31 | } 32 | } 33 | 34 | private void lnkSaveToFile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 35 | { 36 | if (dlgSaveFile.ShowDialog() == DialogResult.OK) 37 | { 38 | //Save license data into local file 39 | File.WriteAllText(dlgSaveFile.FileName, txtLicense.Text.Trim(), Encoding.UTF8); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/QLicense/BASE36.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace QLicense 5 | { 6 | class BASE36 7 | { 8 | private const string _charList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 9 | private static readonly char[] _charArray = _charList.ToCharArray(); 10 | 11 | public static long Decode(string input) 12 | { 13 | long _result = 0; 14 | double _pow = 0; 15 | for (int _i = input.Length - 1; _i >= 0; _i--) 16 | { 17 | char _c = input[_i]; 18 | int pos = _charList.IndexOf(_c); 19 | if (pos > -1) 20 | _result += pos * (long)Math.Pow(_charList.Length, _pow); 21 | else 22 | return -1; 23 | _pow++; 24 | } 25 | return _result; 26 | } 27 | 28 | public static string Encode(ulong input) 29 | { 30 | StringBuilder _sb = new StringBuilder(); 31 | do 32 | { 33 | _sb.Append(_charArray[input % (ulong)_charList.Length]); 34 | input /= (ulong)_charList.Length; 35 | } while (input != 0); 36 | 37 | return Reverse(_sb.ToString()); 38 | } 39 | 40 | private static string Reverse(string s) 41 | { 42 | var charArray = s.ToCharArray(); 43 | Array.Reverse(charArray); 44 | return new string(charArray); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/QLicense/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("QLicense")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("QLicense")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("38832d8a-c528-4c89-a056-b0eebbcfe8ee")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /Demo/DemoLicense/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoLicense")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DemoLicense")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9f0bd6df-f288-451b-828e-6431e5441db8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.2.0.0")] 36 | [assembly: AssemblyFileVersion("1.2.0.0")] 37 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoWinFormApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DemoWinFormApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("01f6d760-d0d5-45cb-b730-afbaf298c7d1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.2.0.0")] 36 | [assembly: AssemblyFileVersion("1.2.0.0")] 37 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoActivationTool")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DemoActivationTool")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("32E65923-1A34-4CF6-9E5B-A2B5CEE3F686")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ActivationControls4Win")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ActivationControls4Win")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7e16d9ce-4360-4c17-8fc2-73c83c5b2fa5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmActivation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using System.IO; 4 | 5 | namespace DemoWinFormApp 6 | { 7 | public partial class frmActivation : Form 8 | { 9 | public byte[] CertificatePublicKeyData { private get; set; } 10 | 11 | public frmActivation() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | private void btnCancel_Click(object sender, EventArgs e) 17 | { 18 | if (MessageBox.Show("Are you sure to cancel?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 19 | { 20 | this.Close(); 21 | } 22 | } 23 | 24 | private void frmActivation_Load(object sender, EventArgs e) 25 | { 26 | 27 | //Assign the application information values to the license control 28 | licActCtrl.AppName = "DemoWinFormApp"; 29 | licActCtrl.LicenseObjectType = typeof(DemoLicense.MyLicense); 30 | licActCtrl.CertificatePublicKeyData = this.CertificatePublicKeyData; 31 | //Display the device unique ID 32 | licActCtrl.ShowUID(); 33 | } 34 | 35 | private void btnOK_Click(object sender, EventArgs e) 36 | { 37 | //Call license control to validate the license string 38 | if (licActCtrl.ValidateLicense()) 39 | { 40 | //If license if valid, save the license string into a local file 41 | File.WriteAllText(Path.Combine(Application.StartupPath, "license.lic"), licActCtrl.LicenseBASE64String); 42 | 43 | MessageBox.Show("License accepted, the application will be close. Please restart it later", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); 44 | 45 | this.Close(); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/LicenseActivateControl.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/frmMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using System.IO; 4 | using System.Security; 5 | using System.Reflection; 6 | using QLicense; 7 | using DemoLicense; 8 | 9 | namespace DemoActivationTool 10 | { 11 | public partial class frmMain : Form 12 | { 13 | private byte[] _certPubicKeyData; 14 | private SecureString _certPwd = new SecureString(); 15 | 16 | public frmMain() 17 | { 18 | InitializeComponent(); 19 | 20 | _certPwd.AppendChar('d'); 21 | _certPwd.AppendChar('e'); 22 | _certPwd.AppendChar('m'); 23 | _certPwd.AppendChar('o'); 24 | } 25 | 26 | private void frmMain_Load(object sender, EventArgs e) 27 | { 28 | //Read public key from assembly 29 | Assembly _assembly = Assembly.GetExecutingAssembly(); 30 | using (MemoryStream _mem = new MemoryStream()) 31 | { 32 | _assembly.GetManifestResourceStream("DemoActivationTool.LicenseSign.pfx").CopyTo(_mem); 33 | 34 | _certPubicKeyData = _mem.ToArray(); 35 | } 36 | 37 | //Initialize the path for the certificate to sign the XML license file 38 | licSettings.CertificatePrivateKeyData = _certPubicKeyData; 39 | licSettings.CertificatePassword = _certPwd; 40 | 41 | //Initialize a new license object 42 | licSettings.License = new MyLicense(); 43 | } 44 | 45 | private void licSettings_OnLicenseGenerated(object sender, QLicense.Windows.Controls.LicenseGeneratedEventArgs e) 46 | { 47 | //Event raised when license string is generated. Just show it in the text box 48 | licString.LicenseString = e.LicenseBASE64String; 49 | } 50 | 51 | 52 | private void btnGenSvrMgmLic_Click(object sender, EventArgs e) 53 | { 54 | //Event raised when "Generate License" button is clicked. 55 | //Call the core library to generate the license 56 | licString.LicenseString = LicenseHandler.GenerateLicenseBASE64String( 57 | new MyLicense(), 58 | _certPubicKeyData, 59 | _certPwd); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DemoWinFormApp 2 | { 3 | partial class frmMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.licInfo = new QLicense.Windows.Controls.LicenseInfoControl(); 32 | this.SuspendLayout(); 33 | // 34 | // licInfo 35 | // 36 | this.licInfo.DateFormat = null; 37 | this.licInfo.DateTimeFormat = null; 38 | this.licInfo.Location = new System.Drawing.Point(12, 12); 39 | this.licInfo.Name = "licInfo"; 40 | this.licInfo.Size = new System.Drawing.Size(300, 300); 41 | this.licInfo.TabIndex = 0; 42 | // 43 | // frmMain 44 | // 45 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 46 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 47 | this.ClientSize = new System.Drawing.Size(324, 330); 48 | this.Controls.Add(this.licInfo); 49 | this.Name = "frmMain"; 50 | this.Text = "DemoWinFormApp"; 51 | this.Shown += new System.EventHandler(this.frmMain_Shown); 52 | this.ResumeLayout(false); 53 | 54 | } 55 | 56 | #endregion 57 | 58 | private QLicense.Windows.Controls.LicenseInfoControl licInfo; 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("ActivationControls4Wpf")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("ActivationControls4Wpf")] 15 | [assembly: AssemblyCopyright("Copyright © 2018")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Demo/DemoLicense/MyLicense.cs: -------------------------------------------------------------------------------- 1 | using QLicense; 2 | using System.ComponentModel; 3 | using System.Xml.Serialization; 4 | 5 | namespace DemoLicense 6 | { 7 | public class MyLicense : QLicense.LicenseEntity 8 | { 9 | [DisplayName("Enable Feature 01")] 10 | [Category("License Options")] 11 | [XmlElement("EnableFeature01")] 12 | [ShowInLicenseInfo(true, "Enable Feature 01", ShowInLicenseInfoAttribute.FormatType.String)] 13 | public bool EnableFeature01 { get; set; } 14 | 15 | [DisplayName("Enable Feature 02")] 16 | [Category("License Options")] 17 | [XmlElement("EnableFeature02")] 18 | [ShowInLicenseInfo(true, "Enable Feature 02", ShowInLicenseInfoAttribute.FormatType.String)] 19 | public bool EnableFeature02 { get; set; } 20 | 21 | 22 | [DisplayName("Enable Feature 03")] 23 | [Category("License Options")] 24 | [XmlElement("EnableFeature03")] 25 | [ShowInLicenseInfo(true, "Enable Feature 03", ShowInLicenseInfoAttribute.FormatType.String)] 26 | public bool EnableFeature03 { get; set; } 27 | 28 | public MyLicense() 29 | { 30 | //Initialize app name for the license 31 | this.AppName = "DemoWinFormApp"; 32 | } 33 | 34 | public override LicenseStatus DoExtraValidation(out string validationMsg) 35 | { 36 | LicenseStatus _licStatus = LicenseStatus.UNDEFINED; 37 | validationMsg = string.Empty; 38 | 39 | switch (this.Type) 40 | { 41 | case LicenseTypes.Single: 42 | //For Single License, check whether UID is matched 43 | if (this.UID == LicenseHandler.GenerateUID(this.AppName)) 44 | { 45 | _licStatus = LicenseStatus.VALID; 46 | } 47 | else 48 | { 49 | validationMsg = "The license is NOT for this copy!"; 50 | _licStatus = LicenseStatus.INVALID; 51 | } 52 | break; 53 | case LicenseTypes.Volume: 54 | //No UID checking for Volume License 55 | _licStatus = LicenseStatus.VALID; 56 | break; 57 | default: 58 | validationMsg = "Invalid license"; 59 | _licStatus= LicenseStatus.INVALID; 60 | break; 61 | } 62 | 63 | return _licStatus; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseInfoControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense.Windows.Controls 2 | { 3 | partial class LicenseInfoControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LicenseInfoControl)); 32 | this.grpbxLicInfo = new System.Windows.Forms.GroupBox(); 33 | this.txtLicInfo = new System.Windows.Forms.TextBox(); 34 | this.grpbxLicInfo.SuspendLayout(); 35 | this.SuspendLayout(); 36 | // 37 | // grpbxLicInfo 38 | // 39 | resources.ApplyResources(this.grpbxLicInfo, "grpbxLicInfo"); 40 | this.grpbxLicInfo.Controls.Add(this.txtLicInfo); 41 | this.grpbxLicInfo.Name = "grpbxLicInfo"; 42 | this.grpbxLicInfo.TabStop = false; 43 | // 44 | // txtLicInfo 45 | // 46 | resources.ApplyResources(this.txtLicInfo, "txtLicInfo"); 47 | this.txtLicInfo.Name = "txtLicInfo"; 48 | this.txtLicInfo.ReadOnly = true; 49 | // 50 | // LicenseInfoControl 51 | // 52 | resources.ApplyResources(this, "$this"); 53 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 54 | this.Controls.Add(this.grpbxLicInfo); 55 | this.Name = "LicenseInfoControl"; 56 | this.grpbxLicInfo.ResumeLayout(false); 57 | this.grpbxLicInfo.PerformLayout(); 58 | this.ResumeLayout(false); 59 | 60 | } 61 | 62 | #endregion 63 | 64 | private System.Windows.Forms.GroupBox grpbxLicInfo; 65 | private System.Windows.Forms.TextBox txtLicInfo; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Demo/DemoLicense/DemoLicense.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9F0BD6DF-F288-451B-828E-6431E5441DB8} 8 | Library 9 | Properties 10 | DemoLicense 11 | DemoLicense 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {1980e43f-c5e4-4a2b-95a6-1aebdc7ee2b7} 47 | QLicense 48 | 49 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseActivateControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace QLicense.Windows.Controls 5 | { 6 | public partial class LicenseActivateControl : UserControl 7 | { 8 | public string AppName { get; set; } 9 | 10 | public byte[] CertificatePublicKeyData { private get; set; } 11 | 12 | public bool ShowMessageAfterValidation { get; set; } 13 | 14 | public Type LicenseObjectType { get; set; } 15 | 16 | public string LicenseBASE64String 17 | { 18 | get 19 | { 20 | return txtLicense.Text.Trim(); 21 | } 22 | } 23 | 24 | public LicenseActivateControl() 25 | { 26 | InitializeComponent(); 27 | 28 | ShowMessageAfterValidation = true; 29 | } 30 | 31 | public void ShowUID() 32 | { 33 | txtUID.Text = LicenseHandler.GenerateUID(AppName); 34 | } 35 | 36 | public bool ValidateLicense() 37 | { 38 | if (string.IsNullOrWhiteSpace(txtLicense.Text)) 39 | { 40 | MessageBox.Show("Please input license", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning); 41 | return false; 42 | } 43 | 44 | //Check the activation string 45 | LicenseStatus _licStatus= LicenseStatus.UNDEFINED; 46 | string _msg = string.Empty; 47 | LicenseEntity _lic = LicenseHandler.ParseLicenseFromBASE64String(LicenseObjectType, txtLicense.Text.Trim(), CertificatePublicKeyData, out _licStatus, out _msg); 48 | switch (_licStatus) 49 | { 50 | case LicenseStatus.VALID: 51 | if (ShowMessageAfterValidation) 52 | { 53 | MessageBox.Show(_msg, "License is valid", MessageBoxButtons.OK, MessageBoxIcon.Information); 54 | } 55 | 56 | return true; 57 | 58 | case LicenseStatus.CRACKED: 59 | case LicenseStatus.INVALID: 60 | case LicenseStatus.UNDEFINED: 61 | if (ShowMessageAfterValidation) 62 | { 63 | MessageBox.Show(_msg, "License is INVALID", MessageBoxButtons.OK, MessageBoxIcon.Error); 64 | } 65 | 66 | return false; 67 | 68 | default: 69 | return false; 70 | } 71 | } 72 | 73 | 74 | private void lnkCopy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 75 | { 76 | Clipboard.SetText(txtUID.Text); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/LicenseActivateControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using QLicense; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace ActivationControls4Wpf 7 | { 8 | /// 9 | /// Interaction logic for LicenseActivateControl.xaml 10 | /// 11 | public partial class LicenseActivateControl : UserControl 12 | { 13 | 14 | public string AppName { get; set; } 15 | 16 | public byte[] CertificatePublicKeyData { get; set; } 17 | 18 | public bool ShowMessageAfterValidation { get; set; } 19 | 20 | public Type LicenseObjectType { get; set; } 21 | 22 | public string LicenseBASE64String 23 | { 24 | get 25 | { 26 | return this.txtLicense.Text.Trim(); 27 | } 28 | } 29 | 30 | public LicenseActivateControl() 31 | { 32 | InitializeComponent(); 33 | } 34 | 35 | public void ShowUID() 36 | { 37 | this.txtUID.Text = LicenseHandler.GenerateUID(AppName); 38 | } 39 | 40 | public bool ValidateLicense() 41 | { 42 | if (string.IsNullOrWhiteSpace(txtLicense.Text)) 43 | { 44 | MessageBox.Show("Please input license", string.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); 45 | return false; 46 | } 47 | 48 | //Check the activation string 49 | LicenseStatus _licStatus = LicenseStatus.UNDEFINED; 50 | string _msg = string.Empty; 51 | try 52 | { 53 | LicenseEntity _lic = LicenseHandler.ParseLicenseFromBASE64String(LicenseObjectType, txtLicense.Text.Trim(), CertificatePublicKeyData, out _licStatus, out _msg); 54 | switch (_licStatus) 55 | { 56 | case LicenseStatus.VALID: 57 | if (ShowMessageAfterValidation) 58 | { 59 | MessageBox.Show(_msg, "License is valid", MessageBoxButton.OK, MessageBoxImage.Information); 60 | } 61 | 62 | return true; 63 | 64 | case LicenseStatus.CRACKED: 65 | case LicenseStatus.INVALID: 66 | case LicenseStatus.UNDEFINED: 67 | if (ShowMessageAfterValidation) 68 | { 69 | MessageBox.Show(_msg, "License is INVALID", MessageBoxButton.OK, MessageBoxImage.Error); 70 | } 71 | 72 | return false; 73 | 74 | default: 75 | return false; 76 | } 77 | } 78 | catch (Exception e) 79 | { 80 | 81 | throw e; 82 | } 83 | 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DemoWinFormApp.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DemoWinFormApp.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DemoActivationTool.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DemoActivationTool.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ActivationControls4Wpf.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ActivationControls4Wpf.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Core/QLicense/QLicense.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7} 8 | Library 9 | Properties 10 | QLicense 11 | QLicense 12 | v4.7.2 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | 38 | 39 | QLicense.snk 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Windows.Forms; 4 | using System.Reflection; 5 | using QLicense; 6 | using DemoLicense; 7 | 8 | namespace DemoWinFormApp 9 | { 10 | public partial class frmMain : Form 11 | { 12 | 13 | byte[] _certPubicKeyData; 14 | public frmMain() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | 20 | private void frmMain_Shown(object sender, EventArgs e) 21 | { 22 | //Initialize variables with default values 23 | MyLicense _lic = null; 24 | string _msg = string.Empty; 25 | LicenseStatus _status = LicenseStatus.UNDEFINED; 26 | 27 | //Read public key from assembly 28 | Assembly _assembly = Assembly.GetExecutingAssembly(); 29 | using (MemoryStream _mem = new MemoryStream()) 30 | { 31 | _assembly.GetManifestResourceStream("DemoWinFormApp.LicenseVerify.cer").CopyTo(_mem); 32 | 33 | _certPubicKeyData = _mem.ToArray(); 34 | } 35 | 36 | //Check if the XML license file exists 37 | if (File.Exists("license.lic")) 38 | { 39 | _lic = (MyLicense)LicenseHandler.ParseLicenseFromBASE64String( 40 | typeof(MyLicense), 41 | File.ReadAllText("license.lic"), 42 | _certPubicKeyData, 43 | out _status, 44 | out _msg); 45 | } 46 | else 47 | { 48 | _status = LicenseStatus.INVALID; 49 | _msg = "Your copy of this application is not activated"; 50 | } 51 | 52 | switch (_status) 53 | { 54 | case LicenseStatus.VALID: 55 | 56 | //TODO: If license is valid, you can do extra checking here 57 | //TODO: E.g., check license expiry date if you have added expiry date property to your license entity 58 | //TODO: Also, you can set feature switch here based on the different properties you added to your license entity 59 | 60 | //Here for demo, just show the license information and RETURN without additional checking 61 | licInfo.ShowLicenseInfo(_lic); 62 | 63 | return; 64 | 65 | default: 66 | //for the other status of license file, show the warning message 67 | //and also popup the activation form for user to activate your application 68 | MessageBox.Show(_msg, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning); 69 | 70 | using (frmActivation frm = new frmActivation()) 71 | { 72 | frm.CertificatePublicKeyData = _certPubicKeyData; 73 | frm.ShowDialog(); 74 | 75 | //Exit the application after activation to reload the license file 76 | //Actually it is not nessessary, you may just call the API to reload the license file 77 | //Here just simplied the demo process 78 | 79 | Application.Exit(); 80 | } 81 | break; 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Core/QLicense/LicenseEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Xml.Serialization; 4 | 5 | namespace QLicense 6 | { 7 | /// 8 | /// This attribute defines whether the property of LicenseEntity object will be shown in LicenseInfoControl 9 | /// 10 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] 11 | public class ShowInLicenseInfoAttribute : Attribute 12 | { 13 | public enum FormatType 14 | { 15 | String, 16 | Date, 17 | DateTime, 18 | EnumDescription, 19 | } 20 | 21 | protected bool _showInLicenseInfo = true; 22 | protected string _displayAs = string.Empty; 23 | protected FormatType _formatType = FormatType.String; 24 | 25 | public ShowInLicenseInfoAttribute() 26 | { 27 | } 28 | 29 | public ShowInLicenseInfoAttribute(bool showInLicenseInfo) 30 | { 31 | if (showInLicenseInfo) 32 | { 33 | throw new Exception("When ShowInLicenseInfo is True, DisplayAs MUST have a value"); 34 | } 35 | _showInLicenseInfo = showInLicenseInfo; 36 | } 37 | 38 | public ShowInLicenseInfoAttribute(bool showInLicenseInfo, string displayAs) 39 | { 40 | _showInLicenseInfo = showInLicenseInfo; 41 | _displayAs = displayAs; 42 | } 43 | public ShowInLicenseInfoAttribute(bool showInLicenseInfo, string displayAs, FormatType dataFormatType) 44 | { 45 | _showInLicenseInfo = showInLicenseInfo; 46 | _displayAs = displayAs; 47 | _formatType = dataFormatType; 48 | } 49 | 50 | public bool ShowInLicenseInfo 51 | { 52 | get 53 | { 54 | return _showInLicenseInfo; 55 | } 56 | } 57 | 58 | public string DisplayAs 59 | { 60 | get 61 | { 62 | return _displayAs; 63 | } 64 | } 65 | 66 | public FormatType DataFormatType 67 | { 68 | get 69 | { 70 | return _formatType; 71 | } 72 | } 73 | } 74 | 75 | 76 | public abstract class LicenseEntity 77 | { 78 | [Browsable(false)] 79 | [XmlIgnore] 80 | [ShowInLicenseInfo(false)] 81 | public string AppName { get; protected set; } 82 | 83 | [Browsable(false)] 84 | [XmlElement("UID")] 85 | [ShowInLicenseInfo(false)] 86 | public string UID { get; set; } 87 | 88 | [Browsable(false)] 89 | [XmlElement("Type")] 90 | [ShowInLicenseInfo(true, "Type", ShowInLicenseInfoAttribute.FormatType.EnumDescription)] 91 | public LicenseTypes Type { get; set; } 92 | 93 | [Browsable(false)] 94 | [XmlElement("CreateDateTime")] 95 | [ShowInLicenseInfo(true, "Creation Time", ShowInLicenseInfoAttribute.FormatType.DateTime)] 96 | public DateTime CreateDateTime { get; set; } 97 | 98 | /// 99 | /// For child class to do extra validation for those extended properties 100 | /// 101 | /// 102 | /// 103 | public abstract LicenseStatus DoExtraValidation(out string validationMsg); 104 | 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmActivation.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DemoWinFormApp 2 | { 3 | partial class frmActivation 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.licActCtrl = new QLicense.Windows.Controls.LicenseActivateControl(); 32 | this.btnCancel = new System.Windows.Forms.Button(); 33 | this.btnOK = new System.Windows.Forms.Button(); 34 | this.SuspendLayout(); 35 | // 36 | // licActCtrl 37 | // 38 | this.licActCtrl.AppName = null; 39 | this.licActCtrl.LicenseObjectType = null; 40 | this.licActCtrl.Location = new System.Drawing.Point(12, 12); 41 | this.licActCtrl.Name = "licActCtrl"; 42 | this.licActCtrl.ShowMessageAfterValidation = true; 43 | this.licActCtrl.Size = new System.Drawing.Size(408, 371); 44 | this.licActCtrl.TabIndex = 0; 45 | // 46 | // btnCancel 47 | // 48 | this.btnCancel.Location = new System.Drawing.Point(338, 393); 49 | this.btnCancel.Name = "btnCancel"; 50 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 51 | this.btnCancel.TabIndex = 1; 52 | this.btnCancel.Text = "&Cancel"; 53 | this.btnCancel.UseVisualStyleBackColor = true; 54 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 55 | // 56 | // btnOK 57 | // 58 | this.btnOK.Location = new System.Drawing.Point(257, 393); 59 | this.btnOK.Name = "btnOK"; 60 | this.btnOK.Size = new System.Drawing.Size(75, 23); 61 | this.btnOK.TabIndex = 2; 62 | this.btnOK.Text = "&OK"; 63 | this.btnOK.UseVisualStyleBackColor = true; 64 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click); 65 | // 66 | // frmActivation 67 | // 68 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 69 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 70 | this.ClientSize = new System.Drawing.Size(425, 428); 71 | this.Controls.Add(this.btnOK); 72 | this.Controls.Add(this.btnCancel); 73 | this.Controls.Add(this.licActCtrl); 74 | this.Name = "frmActivation"; 75 | this.Text = "frmActivation"; 76 | this.Load += new System.EventHandler(this.frmActivation_Load); 77 | this.ResumeLayout(false); 78 | 79 | } 80 | 81 | #endregion 82 | 83 | private QLicense.Windows.Controls.LicenseActivateControl licActCtrl; 84 | private System.Windows.Forms.Button btnCancel; 85 | private System.Windows.Forms.Button btnOK; 86 | } 87 | } -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseSettingsControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security; 3 | using System.Windows.Forms; 4 | 5 | namespace QLicense.Windows.Controls 6 | { 7 | public delegate void LicenseSettingsValidatingHandler(object sender, LicenseSettingsValidatingEventArgs e); 8 | public delegate void LicenseGeneratedHandler(object sender, LicenseGeneratedEventArgs e); 9 | 10 | public partial class LicenseSettingsControl : UserControl 11 | { 12 | 13 | public event LicenseSettingsValidatingHandler OnLicenseSettingsValidating; 14 | public event LicenseGeneratedHandler OnLicenseGenerated; 15 | 16 | protected LicenseEntity _lic; 17 | 18 | public LicenseEntity License 19 | { 20 | set 21 | { 22 | _lic = value; 23 | pgLicenseSettings.SelectedObject = _lic; 24 | } 25 | } 26 | 27 | public byte[] CertificatePrivateKeyData { set; private get; } 28 | 29 | public SecureString CertificatePassword { set; private get; } 30 | 31 | public bool AllowVolumeLicense 32 | { 33 | get 34 | { 35 | return grpbxLicenseType.Enabled; 36 | } 37 | set 38 | { 39 | if (!value) 40 | { 41 | rdoSingleLicense.Checked = true; 42 | } 43 | 44 | grpbxLicenseType.Enabled = value; 45 | } 46 | } 47 | 48 | public LicenseSettingsControl() 49 | { 50 | InitializeComponent(); 51 | } 52 | 53 | 54 | private void LicenseTypeRadioButtons_CheckedChanged(object sender, EventArgs e) 55 | { 56 | txtUID.Text = string.Empty; 57 | 58 | txtUID.Enabled = rdoSingleLicense.Checked; 59 | } 60 | 61 | private void btnGenLicense_Click(object sender, EventArgs e) 62 | { 63 | if (_lic == null) throw new ArgumentException("LicenseEntity is invalid"); 64 | 65 | if (rdoSingleLicense.Checked) 66 | { 67 | if (LicenseHandler.ValidateUIDFormat(txtUID.Text.Trim())) 68 | { 69 | _lic.Type = LicenseTypes.Single; 70 | _lic.UID = txtUID.Text.Trim(); 71 | } 72 | else 73 | { 74 | MessageBox.Show("License UID is blank or invalid", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning); 75 | return; 76 | } 77 | } 78 | else if (rdoVolumeLicense.Checked) 79 | { 80 | _lic.Type = LicenseTypes.Volume; 81 | _lic.UID = string.Empty; 82 | } 83 | 84 | _lic.CreateDateTime = DateTime.Now; 85 | 86 | if (OnLicenseSettingsValidating != null) 87 | { 88 | LicenseSettingsValidatingEventArgs _args = new LicenseSettingsValidatingEventArgs() { License = _lic, CancelGenerating = false }; 89 | 90 | OnLicenseSettingsValidating(this, _args); 91 | 92 | if (_args.CancelGenerating) 93 | { 94 | return; 95 | } 96 | } 97 | 98 | if (OnLicenseGenerated != null) 99 | { 100 | string _licStr = LicenseHandler.GenerateLicenseBASE64String(_lic, CertificatePrivateKeyData, CertificatePassword); 101 | 102 | OnLicenseGenerated(this, new LicenseGeneratedEventArgs() { LicenseBASE64String = _licStr }); 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # LightSwitch generated files 187 | GeneratedArtifacts/ 188 | _Pvt_Extensions/ 189 | ModelManifest.xml -------------------------------------------------------------------------------- /Demo/DemoActivationTool/frmMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DemoActivationTool 2 | { 3 | partial class frmMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.dlgSaveFile = new System.Windows.Forms.SaveFileDialog(); 32 | this.grpbxLicSettings = new System.Windows.Forms.GroupBox(); 33 | this.licSettings = new QLicense.Windows.Controls.LicenseSettingsControl(); 34 | this.licString = new QLicense.Windows.Controls.LicenseStringContainer(); 35 | this.grpbxLicSettings.SuspendLayout(); 36 | this.SuspendLayout(); 37 | // 38 | // dlgSaveFile 39 | // 40 | this.dlgSaveFile.FileName = "License.lic"; 41 | this.dlgSaveFile.Filter = "License File(*.lic)|*.lic"; 42 | // 43 | // grpbxLicSettings 44 | // 45 | this.grpbxLicSettings.Controls.Add(this.licSettings); 46 | this.grpbxLicSettings.Location = new System.Drawing.Point(13, 11); 47 | this.grpbxLicSettings.Name = "grpbxLicSettings"; 48 | this.grpbxLicSettings.Size = new System.Drawing.Size(334, 444); 49 | this.grpbxLicSettings.TabIndex = 6; 50 | this.grpbxLicSettings.TabStop = false; 51 | this.grpbxLicSettings.Text = "License Settings"; 52 | // 53 | // licSettings 54 | // 55 | this.licSettings.AllowVolumeLicense = true; 56 | this.licSettings.Location = new System.Drawing.Point(3, 17); 57 | this.licSettings.Name = "licSettings"; 58 | this.licSettings.Size = new System.Drawing.Size(328, 427); 59 | this.licSettings.TabIndex = 7; 60 | this.licSettings.OnLicenseGenerated += new QLicense.Windows.Controls.LicenseGeneratedHandler(this.licSettings_OnLicenseGenerated); 61 | // 62 | // licString 63 | // 64 | this.licString.LicenseString = ""; 65 | this.licString.Location = new System.Drawing.Point(353, 11); 66 | this.licString.Name = "licString"; 67 | this.licString.Size = new System.Drawing.Size(348, 444); 68 | this.licString.TabIndex = 5; 69 | // 70 | // frmMain 71 | // 72 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 73 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 74 | this.ClientSize = new System.Drawing.Size(713, 467); 75 | this.Controls.Add(this.grpbxLicSettings); 76 | this.Controls.Add(this.licString); 77 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 78 | this.MaximizeBox = false; 79 | this.MinimizeBox = false; 80 | this.Name = "frmMain"; 81 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 82 | this.Text = "Demo Activation Tool"; 83 | this.Load += new System.EventHandler(this.frmMain_Load); 84 | this.grpbxLicSettings.ResumeLayout(false); 85 | this.ResumeLayout(false); 86 | 87 | } 88 | 89 | #endregion 90 | private System.Windows.Forms.SaveFileDialog dlgSaveFile; 91 | private QLicense.Windows.Controls.LicenseStringContainer licString; 92 | private System.Windows.Forms.GroupBox grpbxLicSettings; 93 | private QLicense.Windows.Controls.LicenseSettingsControl licSettings; 94 | } 95 | } 96 | 97 | -------------------------------------------------------------------------------- /QLicense.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QLicense", "Core\QLicense\QLicense.csproj", "{1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActivationControls4Win", "Core\ActivationControls4Win\ActivationControls4Win.csproj", "{DDF06EAC-02DF-4BDA-A883-98B856BC1765}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoWinFormApp", "Demo\DemoWinFormApp\DemoWinFormApp.csproj", "{01F6D760-D0D5-45CB-B730-AFBAF298C7D1}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoActivationTool", "Demo\DemoActivationTool\DemoActivationTool.csproj", "{7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{036B2D67-D093-4477-ABC6-4902676A79B2}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo", "Demo", "{9461EE4C-58DE-49DC-B363-46C0705BEF74}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoLicense", "Demo\DemoLicense\DemoLicense.csproj", "{9F0BD6DF-F288-451B-828E-6431E5441DB8}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActivationControls4Wpf", "Core\ActivationControls4Wpf\ActivationControls4Wpf.csproj", "{8650B5B4-754B-4B77-A26F-08466854BE3A}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Release|Any CPU = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {9F0BD6DF-F288-451B-828E-6431E5441DB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {9F0BD6DF-F288-451B-828E-6431E5441DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {9F0BD6DF-F288-451B-828E-6431E5441DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {9F0BD6DF-F288-451B-828E-6431E5441DB8}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {8650B5B4-754B-4B77-A26F-08466854BE3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {8650B5B4-754B-4B77-A26F-08466854BE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {8650B5B4-754B-4B77-A26F-08466854BE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {8650B5B4-754B-4B77-A26F-08466854BE3A}.Release|Any CPU.Build.0 = Release|Any CPU 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | GlobalSection(NestedProjects) = preSolution 57 | {1980E43F-C5E4-4A2B-95A6-1AEBDC7EE2B7} = {036B2D67-D093-4477-ABC6-4902676A79B2} 58 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765} = {036B2D67-D093-4477-ABC6-4902676A79B2} 59 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1} = {9461EE4C-58DE-49DC-B363-46C0705BEF74} 60 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65} = {9461EE4C-58DE-49DC-B363-46C0705BEF74} 61 | {9F0BD6DF-F288-451B-828E-6431E5441DB8} = {9461EE4C-58DE-49DC-B363-46C0705BEF74} 62 | {8650B5B4-754B-4B77-A26F-08466854BE3A} = {036B2D67-D093-4477-ABC6-4902676A79B2} 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseStringContainer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense.Windows.Controls 2 | { 3 | partial class LicenseStringContainer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LicenseStringContainer)); 32 | this.grpbxLicStr = new System.Windows.Forms.GroupBox(); 33 | this.lnkSaveToFile = new System.Windows.Forms.LinkLabel(); 34 | this.lnkCopy = new System.Windows.Forms.LinkLabel(); 35 | this.txtLicense = new System.Windows.Forms.TextBox(); 36 | this.dlgSaveFile = new System.Windows.Forms.SaveFileDialog(); 37 | this.grpbxLicStr.SuspendLayout(); 38 | this.SuspendLayout(); 39 | // 40 | // grpbxLicStr 41 | // 42 | this.grpbxLicStr.Controls.Add(this.lnkSaveToFile); 43 | this.grpbxLicStr.Controls.Add(this.lnkCopy); 44 | this.grpbxLicStr.Controls.Add(this.txtLicense); 45 | resources.ApplyResources(this.grpbxLicStr, "grpbxLicStr"); 46 | this.grpbxLicStr.Name = "grpbxLicStr"; 47 | this.grpbxLicStr.TabStop = false; 48 | // 49 | // lnkSaveToFile 50 | // 51 | resources.ApplyResources(this.lnkSaveToFile, "lnkSaveToFile"); 52 | this.lnkSaveToFile.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; 53 | this.lnkSaveToFile.Name = "lnkSaveToFile"; 54 | this.lnkSaveToFile.TabStop = true; 55 | this.lnkSaveToFile.VisitedLinkColor = System.Drawing.Color.Blue; 56 | this.lnkSaveToFile.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSaveToFile_LinkClicked); 57 | // 58 | // lnkCopy 59 | // 60 | resources.ApplyResources(this.lnkCopy, "lnkCopy"); 61 | this.lnkCopy.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; 62 | this.lnkCopy.Name = "lnkCopy"; 63 | this.lnkCopy.TabStop = true; 64 | this.lnkCopy.VisitedLinkColor = System.Drawing.Color.Blue; 65 | this.lnkCopy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkCopy_LinkClicked); 66 | // 67 | // txtLicense 68 | // 69 | resources.ApplyResources(this.txtLicense, "txtLicense"); 70 | this.txtLicense.Name = "txtLicense"; 71 | this.txtLicense.ReadOnly = true; 72 | // 73 | // dlgSaveFile 74 | // 75 | this.dlgSaveFile.FileName = "License.lic"; 76 | resources.ApplyResources(this.dlgSaveFile, "dlgSaveFile"); 77 | // 78 | // LicenseStringContainer 79 | // 80 | resources.ApplyResources(this, "$this"); 81 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 82 | this.Controls.Add(this.grpbxLicStr); 83 | this.Name = "LicenseStringContainer"; 84 | this.grpbxLicStr.ResumeLayout(false); 85 | this.grpbxLicStr.PerformLayout(); 86 | this.ResumeLayout(false); 87 | 88 | } 89 | 90 | #endregion 91 | 92 | private System.Windows.Forms.GroupBox grpbxLicStr; 93 | private System.Windows.Forms.LinkLabel lnkSaveToFile; 94 | private System.Windows.Forms.LinkLabel lnkCopy; 95 | private System.Windows.Forms.TextBox txtLicense; 96 | private System.Windows.Forms.SaveFileDialog dlgSaveFile; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseActivateControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense.Windows.Controls 2 | { 3 | partial class LicenseActivateControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LicenseActivateControl)); 32 | this.grpbxLicense = new System.Windows.Forms.GroupBox(); 33 | this.txtLicense = new System.Windows.Forms.TextBox(); 34 | this.grpbxUID = new System.Windows.Forms.GroupBox(); 35 | this.lblUIDTip = new System.Windows.Forms.Label(); 36 | this.lnkCopy = new System.Windows.Forms.LinkLabel(); 37 | this.txtUID = new System.Windows.Forms.TextBox(); 38 | this.grpbxLicense.SuspendLayout(); 39 | this.grpbxUID.SuspendLayout(); 40 | this.SuspendLayout(); 41 | // 42 | // grpbxLicense 43 | // 44 | resources.ApplyResources(this.grpbxLicense, "grpbxLicense"); 45 | this.grpbxLicense.Controls.Add(this.txtLicense); 46 | this.grpbxLicense.Name = "grpbxLicense"; 47 | this.grpbxLicense.TabStop = false; 48 | // 49 | // txtLicense 50 | // 51 | resources.ApplyResources(this.txtLicense, "txtLicense"); 52 | this.txtLicense.Name = "txtLicense"; 53 | // 54 | // grpbxUID 55 | // 56 | resources.ApplyResources(this.grpbxUID, "grpbxUID"); 57 | this.grpbxUID.Controls.Add(this.lblUIDTip); 58 | this.grpbxUID.Controls.Add(this.lnkCopy); 59 | this.grpbxUID.Controls.Add(this.txtUID); 60 | this.grpbxUID.Name = "grpbxUID"; 61 | this.grpbxUID.TabStop = false; 62 | // 63 | // lblUIDTip 64 | // 65 | resources.ApplyResources(this.lblUIDTip, "lblUIDTip"); 66 | this.lblUIDTip.Name = "lblUIDTip"; 67 | // 68 | // lnkCopy 69 | // 70 | resources.ApplyResources(this.lnkCopy, "lnkCopy"); 71 | this.lnkCopy.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; 72 | this.lnkCopy.Name = "lnkCopy"; 73 | this.lnkCopy.TabStop = true; 74 | this.lnkCopy.VisitedLinkColor = System.Drawing.Color.Blue; 75 | this.lnkCopy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkCopy_LinkClicked); 76 | // 77 | // txtUID 78 | // 79 | resources.ApplyResources(this.txtUID, "txtUID"); 80 | this.txtUID.Name = "txtUID"; 81 | this.txtUID.ReadOnly = true; 82 | // 83 | // LicenseActivateControl 84 | // 85 | resources.ApplyResources(this, "$this"); 86 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 87 | this.Controls.Add(this.grpbxLicense); 88 | this.Controls.Add(this.grpbxUID); 89 | this.Name = "LicenseActivateControl"; 90 | this.grpbxLicense.ResumeLayout(false); 91 | this.grpbxLicense.PerformLayout(); 92 | this.grpbxUID.ResumeLayout(false); 93 | this.grpbxUID.PerformLayout(); 94 | this.ResumeLayout(false); 95 | 96 | } 97 | 98 | #endregion 99 | 100 | private System.Windows.Forms.GroupBox grpbxLicense; 101 | private System.Windows.Forms.TextBox txtLicense; 102 | private System.Windows.Forms.GroupBox grpbxUID; 103 | private System.Windows.Forms.Label lblUIDTip; 104 | private System.Windows.Forms.LinkLabel lnkCopy; 105 | private System.Windows.Forms.TextBox txtUID; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/DemoActivationTool.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7E6FF8AE-63E9-4BB2-9ACE-7580CE229F65} 8 | WinExe 9 | Properties 10 | DemoActivationTool 11 | DemoActivationTool 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | DemoActivationTool.Program 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Form 51 | 52 | 53 | frmMain.cs 54 | 55 | 56 | 57 | 58 | frmMain.cs 59 | 60 | 61 | ResXFileCodeGenerator 62 | Resources.Designer.cs 63 | Designer 64 | 65 | 66 | True 67 | Resources.resx 68 | True 69 | 70 | 71 | 72 | SettingsSingleFileGenerator 73 | Settings.Designer.cs 74 | 75 | 76 | True 77 | Settings.settings 78 | True 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | {ddf06eac-02df-4bda-a883-98b856bc1765} 87 | ActivationControls4Win 88 | 89 | 90 | {1980e43f-c5e4-4a2b-95a6-1aebdc7ee2b7} 91 | QLicense 92 | 93 | 94 | {9f0bd6df-f288-451b-828e-6431e5441db8} 95 | DemoLicense 96 | 97 | 98 | 99 | 106 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/ActivationControls4Wpf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8650B5B4-754B-4B77-A26F-08466854BE3A} 8 | Library 9 | Properties 10 | ActivationControls4Wpf 11 | ActivationControls4Wpf 12 | v4.0 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | true 41 | 42 | 43 | ActivationControls4Wpf.snk 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 4.0 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | LicenseActivateControl.xaml 65 | 66 | 67 | Code 68 | 69 | 70 | True 71 | True 72 | Resources.resx 73 | 74 | 75 | True 76 | Settings.settings 77 | True 78 | 79 | 80 | ResXFileCodeGenerator 81 | Resources.Designer.cs 82 | 83 | 84 | 85 | SettingsSingleFileGenerator 86 | Settings.Designer.cs 87 | 88 | 89 | 90 | 91 | 92 | {1980e43f-c5e4-4a2b-95a6-1aebdc7ee2b7} 93 | QLicense 94 | 95 | 96 | 97 | 98 | Designer 99 | MSBuild:Compile 100 | 101 | 102 | 103 | 110 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/DemoWinFormApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {01F6D760-D0D5-45CB-B730-AFBAF298C7D1} 8 | WinExe 9 | Properties 10 | DemoWinFormApp 11 | DemoWinFormApp 12 | v4.0 13 | 512 14 | true 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | ..\..\Core\ActivationControls4Win\obj\Debug\QLicense.Windows.Controls.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Form 52 | 53 | 54 | frmActivation.cs 55 | 56 | 57 | Form 58 | 59 | 60 | frmMain.cs 61 | 62 | 63 | 64 | 65 | frmActivation.cs 66 | 67 | 68 | frmMain.cs 69 | 70 | 71 | ResXFileCodeGenerator 72 | Resources.Designer.cs 73 | Designer 74 | 75 | 76 | True 77 | Resources.resx 78 | True 79 | 80 | 81 | 82 | SettingsSingleFileGenerator 83 | Settings.Designer.cs 84 | 85 | 86 | True 87 | Settings.settings 88 | True 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | {1980e43f-c5e4-4a2b-95a6-1aebdc7ee2b7} 97 | QLicense 98 | 99 | 100 | {9f0bd6df-f288-451b-828e-6431e5441db8} 101 | DemoLicense 102 | 103 | 104 | 105 | 112 | -------------------------------------------------------------------------------- /Core/QLicense/HardwareInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Management; 5 | using System.Security.Cryptography; 6 | 7 | 8 | namespace QLicense 9 | { 10 | class HardwareInfo 11 | { 12 | /// 13 | /// Get volume serial number of drive C 14 | /// 15 | /// 16 | private static string GetDiskVolumeSerialNumber() 17 | { 18 | try 19 | { 20 | ManagementObject _disk = new ManagementObject(@"Win32_LogicalDisk.deviceid=""c:"""); 21 | _disk.Get(); 22 | return _disk["VolumeSerialNumber"].ToString(); 23 | } 24 | catch 25 | { 26 | return string.Empty; 27 | } 28 | } 29 | 30 | /// 31 | /// Get CPU ID 32 | /// 33 | /// 34 | private static string GetProcessorId() 35 | { 36 | try 37 | { 38 | ManagementObjectSearcher _mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor"); 39 | ManagementObjectCollection _mbsList = _mbs.Get(); 40 | string _id = string.Empty; 41 | foreach (ManagementObject _mo in _mbsList) 42 | { 43 | _id= _mo["ProcessorId"].ToString(); 44 | break; 45 | } 46 | 47 | return _id; 48 | 49 | } 50 | catch 51 | { 52 | return string.Empty; 53 | } 54 | 55 | } 56 | 57 | /// 58 | /// Get motherboard serial number 59 | /// 60 | /// 61 | private static string GetMotherboardID() 62 | { 63 | 64 | try 65 | { 66 | ManagementObjectSearcher _mbs = new ManagementObjectSearcher("Select SerialNumber From Win32_BaseBoard"); 67 | ManagementObjectCollection _mbsList = _mbs.Get(); 68 | string _id = string.Empty; 69 | foreach (ManagementObject _mo in _mbsList) 70 | { 71 | _id = _mo["SerialNumber"].ToString(); 72 | break; 73 | } 74 | 75 | return _id; 76 | } 77 | catch 78 | { 79 | return string.Empty; 80 | } 81 | 82 | } 83 | 84 | private static IEnumerable SplitInParts(string input, int partLength) 85 | { 86 | if (input == null) 87 | throw new ArgumentNullException("input"); 88 | if (partLength <= 0) 89 | throw new ArgumentException("Part length has to be positive.", "partLength"); 90 | 91 | for (int i = 0; i < input.Length; i += partLength) 92 | yield return input.Substring(i, Math.Min(partLength, input.Length - i)); 93 | } 94 | 95 | /// 96 | /// Combine CPU ID, Disk C Volume Serial Number and Motherboard Serial Number as device Id 97 | /// 98 | /// 99 | public static string GenerateUID(string appName) 100 | { 101 | //Combine the IDs and get bytes 102 | string _id = string.Concat(appName, GetProcessorId(), GetMotherboardID(), GetDiskVolumeSerialNumber()); 103 | byte[] _byteIds = Encoding.UTF8.GetBytes(_id); 104 | 105 | //Use MD5 to get the fixed length checksum of the ID string 106 | MD5CryptoServiceProvider _md5 = new MD5CryptoServiceProvider(); 107 | byte[] _checksum = _md5.ComputeHash(_byteIds); 108 | 109 | //Convert checksum into 4 ulong parts and use BASE36 to encode both 110 | string _part1Id = BASE36.Encode(BitConverter.ToUInt32(_checksum, 0)); 111 | string _part2Id = BASE36.Encode(BitConverter.ToUInt32(_checksum, 4)); 112 | string _part3Id = BASE36.Encode(BitConverter.ToUInt32(_checksum, 8)); 113 | string _part4Id = BASE36.Encode(BitConverter.ToUInt32(_checksum, 12)); 114 | 115 | //Concat these 4 part into one string 116 | return string.Format("{0}-{1}-{2}-{3}", _part1Id, _part2Id, _part3Id, _part4Id); 117 | } 118 | 119 | public static byte[] GetUIDInBytes(string UID) 120 | { 121 | //Split 4 part Id into 4 ulong 122 | string[] _ids = UID.Split('-'); 123 | 124 | if (_ids.Length != 4) throw new ArgumentException("Wrong UID"); 125 | 126 | //Combine 4 part Id into one byte array 127 | byte[] _value = new byte[16]; 128 | Buffer.BlockCopy(BitConverter.GetBytes(BASE36.Decode(_ids[0])), 0, _value, 0, 8); 129 | Buffer.BlockCopy(BitConverter.GetBytes(BASE36.Decode(_ids[1])), 0, _value, 8, 8); 130 | Buffer.BlockCopy(BitConverter.GetBytes(BASE36.Decode(_ids[2])), 0, _value, 16, 8); 131 | Buffer.BlockCopy(BitConverter.GetBytes(BASE36.Decode(_ids[3])), 0, _value, 24, 8); 132 | 133 | return _value; 134 | } 135 | 136 | public static bool ValidateUIDFormat(string UID) 137 | { 138 | if (!string.IsNullOrWhiteSpace(UID)) 139 | { 140 | string[] _ids = UID.Split('-'); 141 | 142 | return (_ids.Length == 4); 143 | } 144 | else 145 | { 146 | return false; 147 | } 148 | 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseInfoControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Windows.Forms; 4 | using System.Reflection; 5 | using System.ComponentModel; 6 | 7 | namespace QLicense.Windows.Controls 8 | { 9 | public partial class LicenseInfoControl : UserControl 10 | { 11 | public string DateFormat { get; set; } 12 | 13 | public string DateTimeFormat { get; set; } 14 | 15 | public LicenseInfoControl() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public void ShowTextOnly(string text) 21 | { 22 | txtLicInfo.Text = text.Trim(); 23 | } 24 | 25 | public void ShowLicenseInfo(LicenseEntity license) 26 | { 27 | ShowLicenseInfo(license, string.Empty); 28 | } 29 | 30 | 31 | public void ShowLicenseInfo(LicenseEntity license, string additionalInfo) 32 | { 33 | try 34 | { 35 | StringBuilder _sb = new StringBuilder(512); 36 | 37 | Type _typeLic = license.GetType(); 38 | PropertyInfo[] _props = _typeLic.GetProperties(); 39 | 40 | object _value = null; 41 | string _formatedValue = string.Empty; 42 | foreach (PropertyInfo _p in _props) 43 | { 44 | try 45 | { 46 | ShowInLicenseInfoAttribute _showAttr = (ShowInLicenseInfoAttribute)Attribute.GetCustomAttribute(_p, typeof(ShowInLicenseInfoAttribute)); 47 | if (_showAttr != null && _showAttr.ShowInLicenseInfo) 48 | { 49 | _value = _p.GetValue(license, null); 50 | _sb.Append(_showAttr.DisplayAs); 51 | _sb.Append(": "); 52 | 53 | //Append value and apply the format 54 | if (_value != null) 55 | { 56 | switch (_showAttr.DataFormatType) 57 | { 58 | case ShowInLicenseInfoAttribute.FormatType.String: 59 | _formatedValue = _value.ToString(); 60 | break; 61 | case ShowInLicenseInfoAttribute.FormatType.Date: 62 | if (_p.PropertyType == typeof(DateTime) && !string.IsNullOrWhiteSpace(DateFormat)) 63 | { 64 | _formatedValue = ((DateTime)_value).ToString(DateFormat); 65 | } 66 | else 67 | { 68 | _formatedValue = _value.ToString(); 69 | } 70 | break; 71 | case ShowInLicenseInfoAttribute.FormatType.DateTime: 72 | if (_p.PropertyType == typeof(DateTime) && !string.IsNullOrWhiteSpace(DateTimeFormat)) 73 | { 74 | _formatedValue = ((DateTime)_value).ToString(DateTimeFormat); 75 | } 76 | else 77 | { 78 | _formatedValue = _value.ToString(); 79 | } 80 | break; 81 | case ShowInLicenseInfoAttribute.FormatType.EnumDescription: 82 | string _name = Enum.GetName(_p.PropertyType, _value); 83 | if (_name != null) 84 | { 85 | FieldInfo _fi = _p.PropertyType.GetField(_name); 86 | DescriptionAttribute _dna = (DescriptionAttribute)Attribute.GetCustomAttribute(_fi, typeof(DescriptionAttribute)); 87 | if (_dna != null) 88 | _formatedValue = _dna.Description; 89 | else 90 | _formatedValue = _value.ToString(); 91 | } 92 | else 93 | { 94 | _formatedValue = _value.ToString(); 95 | } 96 | break; 97 | } 98 | 99 | _sb.Append(_formatedValue); 100 | } 101 | 102 | _sb.Append("\r\n"); 103 | } 104 | } 105 | catch 106 | { 107 | //Ignore exeption 108 | } 109 | } 110 | 111 | 112 | if (!string.IsNullOrWhiteSpace(additionalInfo)) 113 | { 114 | _sb.Append(additionalInfo.Trim()); 115 | } 116 | 117 | txtLicInfo.Text = _sb.ToString(); 118 | } 119 | catch (Exception ex) 120 | { 121 | txtLicInfo.Text = ex.Message; 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/ActivationControls4Win.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {DDF06EAC-02DF-4BDA-A883-98B856BC1765} 8 | Library 9 | Properties 10 | QLicense.Windows.Controls 11 | QLicense.Windows.Controls 12 | v4.7.2 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | 38 | 39 | ActivationControls4Win.snk 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | UserControl 55 | 56 | 57 | LicenseActivateControl.cs 58 | 59 | 60 | 61 | UserControl 62 | 63 | 64 | LicenseInfoControl.cs 65 | 66 | 67 | 68 | UserControl 69 | 70 | 71 | LicenseSettingsControl.cs 72 | 73 | 74 | UserControl 75 | 76 | 77 | LicenseStringContainer.cs 78 | 79 | 80 | 81 | 82 | 83 | 84 | LicenseActivateControl.cs 85 | 86 | 87 | LicenseActivateControl.cs 88 | 89 | 90 | LicenseInfoControl.cs 91 | 92 | 93 | LicenseInfoControl.cs 94 | 95 | 96 | LicenseSettingsControl.cs 97 | 98 | 99 | LicenseSettingsControl.cs 100 | 101 | 102 | LicenseStringContainer.cs 103 | 104 | 105 | LicenseStringContainer.cs 106 | 107 | 108 | 109 | 110 | {1980e43f-c5e4-4a2b-95a6-1aebdc7ee2b7} 111 | QLicense 112 | 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Core/ActivationControls4Wpf/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmMain.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Demo/DemoWinFormApp/frmActivation.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseInfoControl.zh-Hans.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 许可证信息 122 | 123 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseSettingsControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace QLicense.Windows.Controls 2 | { 3 | partial class LicenseSettingsControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LicenseSettingsControl)); 32 | this.grpbxLicenseType = new System.Windows.Forms.GroupBox(); 33 | this.rdoVolumeLicense = new System.Windows.Forms.RadioButton(); 34 | this.rdoSingleLicense = new System.Windows.Forms.RadioButton(); 35 | this.grpbxUniqueID = new System.Windows.Forms.GroupBox(); 36 | this.txtUID = new System.Windows.Forms.TextBox(); 37 | this.grpbxLicenseInfo = new System.Windows.Forms.GroupBox(); 38 | this.pgLicenseSettings = new System.Windows.Forms.PropertyGrid(); 39 | this.btnGenLicense = new System.Windows.Forms.Button(); 40 | this.grpbxLicenseType.SuspendLayout(); 41 | this.grpbxUniqueID.SuspendLayout(); 42 | this.grpbxLicenseInfo.SuspendLayout(); 43 | this.SuspendLayout(); 44 | // 45 | // grpbxLicenseType 46 | // 47 | resources.ApplyResources(this.grpbxLicenseType, "grpbxLicenseType"); 48 | this.grpbxLicenseType.Controls.Add(this.rdoVolumeLicense); 49 | this.grpbxLicenseType.Controls.Add(this.rdoSingleLicense); 50 | this.grpbxLicenseType.Name = "grpbxLicenseType"; 51 | this.grpbxLicenseType.TabStop = false; 52 | // 53 | // rdoVolumeLicense 54 | // 55 | resources.ApplyResources(this.rdoVolumeLicense, "rdoVolumeLicense"); 56 | this.rdoVolumeLicense.Name = "rdoVolumeLicense"; 57 | this.rdoVolumeLicense.UseVisualStyleBackColor = true; 58 | this.rdoVolumeLicense.CheckedChanged += new System.EventHandler(this.LicenseTypeRadioButtons_CheckedChanged); 59 | // 60 | // rdoSingleLicense 61 | // 62 | resources.ApplyResources(this.rdoSingleLicense, "rdoSingleLicense"); 63 | this.rdoSingleLicense.Checked = true; 64 | this.rdoSingleLicense.Name = "rdoSingleLicense"; 65 | this.rdoSingleLicense.TabStop = true; 66 | this.rdoSingleLicense.UseVisualStyleBackColor = true; 67 | this.rdoSingleLicense.CheckedChanged += new System.EventHandler(this.LicenseTypeRadioButtons_CheckedChanged); 68 | // 69 | // grpbxUniqueID 70 | // 71 | resources.ApplyResources(this.grpbxUniqueID, "grpbxUniqueID"); 72 | this.grpbxUniqueID.Controls.Add(this.txtUID); 73 | this.grpbxUniqueID.Name = "grpbxUniqueID"; 74 | this.grpbxUniqueID.TabStop = false; 75 | // 76 | // txtUID 77 | // 78 | resources.ApplyResources(this.txtUID, "txtUID"); 79 | this.txtUID.Name = "txtUID"; 80 | // 81 | // grpbxLicenseInfo 82 | // 83 | resources.ApplyResources(this.grpbxLicenseInfo, "grpbxLicenseInfo"); 84 | this.grpbxLicenseInfo.Controls.Add(this.pgLicenseSettings); 85 | this.grpbxLicenseInfo.Name = "grpbxLicenseInfo"; 86 | this.grpbxLicenseInfo.TabStop = false; 87 | // 88 | // pgLicenseSettings 89 | // 90 | resources.ApplyResources(this.pgLicenseSettings, "pgLicenseSettings"); 91 | this.pgLicenseSettings.Name = "pgLicenseSettings"; 92 | this.pgLicenseSettings.PropertySort = System.Windows.Forms.PropertySort.NoSort; 93 | // 94 | // btnGenLicense 95 | // 96 | resources.ApplyResources(this.btnGenLicense, "btnGenLicense"); 97 | this.btnGenLicense.Name = "btnGenLicense"; 98 | this.btnGenLicense.UseVisualStyleBackColor = true; 99 | this.btnGenLicense.Click += new System.EventHandler(this.btnGenLicense_Click); 100 | // 101 | // LicenseSettingsControl 102 | // 103 | resources.ApplyResources(this, "$this"); 104 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 105 | this.Controls.Add(this.grpbxLicenseType); 106 | this.Controls.Add(this.grpbxUniqueID); 107 | this.Controls.Add(this.grpbxLicenseInfo); 108 | this.Controls.Add(this.btnGenLicense); 109 | this.Name = "LicenseSettingsControl"; 110 | this.grpbxLicenseType.ResumeLayout(false); 111 | this.grpbxLicenseType.PerformLayout(); 112 | this.grpbxUniqueID.ResumeLayout(false); 113 | this.grpbxUniqueID.PerformLayout(); 114 | this.grpbxLicenseInfo.ResumeLayout(false); 115 | this.ResumeLayout(false); 116 | 117 | } 118 | 119 | #endregion 120 | 121 | private System.Windows.Forms.GroupBox grpbxLicenseType; 122 | private System.Windows.Forms.RadioButton rdoVolumeLicense; 123 | private System.Windows.Forms.RadioButton rdoSingleLicense; 124 | private System.Windows.Forms.GroupBox grpbxUniqueID; 125 | private System.Windows.Forms.TextBox txtUID; 126 | private System.Windows.Forms.GroupBox grpbxLicenseInfo; 127 | private System.Windows.Forms.PropertyGrid pgLicenseSettings; 128 | private System.Windows.Forms.Button btnGenLicense; 129 | 130 | 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Demo/DemoActivationTool/frmMain.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 66 125 | 126 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseSettingsControl.zh-Hans.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 生成许可证[&L] 122 | 123 | 124 | 许可证信息 125 | 126 | 127 | 许可证类型 128 | 129 | 130 | 许可证标识号 131 | 132 | 133 | 单机许可 134 | 135 | 136 | 批量许可 137 | 138 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseStringContainer.zh-Hans.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 67, 13 123 | 124 | 125 | 保存到文件 126 | 127 | 128 | 复制到剪贴板 129 | 130 | 131 | 许可证字符串 132 | 133 | 134 | 许可证文件(*.lic)|*.lic 135 | 136 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseActivateControl.zh-Hans.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 许可证 122 | 123 | 124 | 许可证标识号 125 | 126 | 127 | 128 | 235, 13 129 | 130 | 131 | 在购买许可证时,请提供如下许可证标识号 132 | 133 | 134 | 79, 13 135 | 136 | 137 | 复制到剪贴板 138 | 139 | -------------------------------------------------------------------------------- /Core/QLicense/LicenseHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Security; 4 | using System.Security.Cryptography; 5 | using System.Security.Cryptography.X509Certificates; 6 | using System.Security.Cryptography.Xml; 7 | using System.Xml; 8 | using System.Xml.Serialization; 9 | using System.IO; 10 | 11 | 12 | namespace QLicense 13 | { 14 | /// 15 | /// Usage Guide: 16 | /// Command for creating the certificate 17 | /// >> makecert -pe -ss My -sr CurrentUser -$ commercial -n "CN=" -sky Signature 18 | /// Then export the cert with private key from key store with a password 19 | /// Also export another cert with only public key 20 | /// 21 | public class LicenseHandler 22 | { 23 | 24 | public static string GenerateUID(string appName) 25 | { 26 | return HardwareInfo.GenerateUID(appName); 27 | } 28 | 29 | public static string GenerateLicenseBASE64String(LicenseEntity lic, byte[] certPrivateKeyData, SecureString certFilePwd) 30 | { 31 | //Serialize license object into XML 32 | XmlDocument _licenseObject = new XmlDocument(); 33 | using (StringWriter _writer = new StringWriter()) 34 | { 35 | XmlSerializer _serializer = new XmlSerializer(typeof(LicenseEntity), new Type[] { lic.GetType() }); 36 | 37 | _serializer.Serialize(_writer, lic); 38 | 39 | _licenseObject.LoadXml(_writer.ToString()); 40 | } 41 | 42 | //Get RSA key from certificate 43 | X509Certificate2 cert = new X509Certificate2(certPrivateKeyData, certFilePwd); 44 | 45 | RSA rsaKey = cert.GetRSAPrivateKey(); 46 | 47 | //Sign the XML 48 | SignXML(_licenseObject, rsaKey); 49 | 50 | //Convert the signed XML into BASE64 string 51 | return Convert.ToBase64String(Encoding.UTF8.GetBytes(_licenseObject.OuterXml)); 52 | } 53 | 54 | 55 | 56 | public static LicenseEntity ParseLicenseFromBASE64String(Type licenseObjType, string licenseString, byte[] certPubKeyData, out LicenseStatus licStatus, out string validationMsg) 57 | { 58 | validationMsg = string.Empty; 59 | licStatus = LicenseStatus.UNDEFINED; 60 | 61 | if (string.IsNullOrWhiteSpace(licenseString)) 62 | { 63 | licStatus = LicenseStatus.CRACKED; 64 | return null; 65 | } 66 | 67 | string _licXML = string.Empty; 68 | LicenseEntity _lic = null; 69 | 70 | try 71 | { 72 | //Get RSA key from certificate 73 | X509Certificate2 cert = new X509Certificate2(certPubKeyData); 74 | RSA rsaKey = cert.GetRSAPublicKey(); 75 | 76 | XmlDocument xmlDoc = new XmlDocument(); 77 | 78 | // Load an XML file into the XmlDocument object. 79 | xmlDoc.PreserveWhitespace = true; 80 | xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String(licenseString))); 81 | 82 | // Verify the signature of the signed XML. 83 | if (VerifyXml(xmlDoc, rsaKey)) 84 | { 85 | XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Signature"); 86 | xmlDoc.DocumentElement.RemoveChild(nodeList[0]); 87 | 88 | _licXML = xmlDoc.OuterXml; 89 | 90 | //Deserialize license 91 | XmlSerializer _serializer = new XmlSerializer(typeof(LicenseEntity), new Type[] { licenseObjType }); 92 | using (StringReader _reader = new StringReader(_licXML)) 93 | { 94 | _lic = (LicenseEntity)_serializer.Deserialize(_reader); 95 | } 96 | 97 | licStatus = _lic.DoExtraValidation(out validationMsg); 98 | } 99 | else 100 | { 101 | licStatus = LicenseStatus.INVALID; 102 | } 103 | } 104 | catch 105 | { 106 | licStatus = LicenseStatus.CRACKED; 107 | } 108 | 109 | return _lic; 110 | } 111 | 112 | // Sign an XML file. 113 | // This document cannot be verified unless the verifying 114 | // code has the key with which it was signed. 115 | private static void SignXML(XmlDocument xmlDoc, RSA Key) 116 | { 117 | // Check arguments. 118 | if (xmlDoc == null) 119 | throw new ArgumentException("xmlDoc"); 120 | if (Key == null) 121 | throw new ArgumentException("Key"); 122 | 123 | // Create a SignedXml object. 124 | SignedXml signedXml = new SignedXml(xmlDoc); 125 | 126 | // Add the key to the SignedXml document. 127 | signedXml.SigningKey = Key; 128 | 129 | // Create a reference to be signed. 130 | Reference reference = new Reference(); 131 | reference.Uri = ""; 132 | 133 | // Add an enveloped transformation to the reference. 134 | XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(); 135 | reference.AddTransform(env); 136 | 137 | // Add the reference to the SignedXml object. 138 | signedXml.AddReference(reference); 139 | 140 | // Compute the signature. 141 | signedXml.ComputeSignature(); 142 | 143 | // Get the XML representation of the signature and save 144 | // it to an XmlElement object. 145 | XmlElement xmlDigitalSignature = signedXml.GetXml(); 146 | 147 | // Append the element to the XML document. 148 | xmlDoc.DocumentElement.AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true)); 149 | 150 | } 151 | 152 | // Verify the signature of an XML file against an asymmetric 153 | // algorithm and return the result. 154 | private static Boolean VerifyXml(XmlDocument Doc, RSA Key) 155 | { 156 | // Check arguments. 157 | if (Doc == null) 158 | throw new ArgumentException("Doc"); 159 | if (Key == null) 160 | throw new ArgumentException("Key"); 161 | 162 | // Create a new SignedXml object and pass it 163 | // the XML document class. 164 | SignedXml signedXml = new SignedXml(Doc); 165 | 166 | // Find the "Signature" node and create a new 167 | // XmlNodeList object. 168 | XmlNodeList nodeList = Doc.GetElementsByTagName("Signature"); 169 | 170 | // Throw an exception if no signature was found. 171 | if (nodeList.Count <= 0) 172 | { 173 | throw new CryptographicException("Verification failed: No Signature was found in the document."); 174 | } 175 | 176 | // This example only supports one signature for 177 | // the entire XML document. Throw an exception 178 | // if more than one signature was found. 179 | if (nodeList.Count >= 2) 180 | { 181 | throw new CryptographicException("Verification failed: More that one signature was found for the document."); 182 | } 183 | 184 | // Load the first node. 185 | signedXml.LoadXml((XmlElement)nodeList[0]); 186 | 187 | // Check the signature and return the result. 188 | return signedXml.CheckSignature(Key); 189 | } 190 | 191 | public static bool ValidateUIDFormat(string UID) 192 | { 193 | return HardwareInfo.ValidateUIDFormat(UID); 194 | } 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /Core/ActivationControls4Win/LicenseInfoControl.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 300, 300 123 | 124 | 125 | 300, 300 126 | 127 | 128 | System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 129 | 130 | 131 | 3, 16 132 | 133 | 134 | 135 | False 136 | 137 | 138 | 139 | Fill 140 | 141 | 142 | License Information 143 | 144 | 145 | True 146 | 147 | 148 | grpbxLicInfo 149 | 150 | 151 | 0 152 | 153 | 154 | 0 155 | 156 | 157 | txtLicInfo 158 | 159 | 160 | 294, 281 161 | 162 | 163 | grpbxLicInfo 164 | 165 | 166 | System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 167 | 168 | 169 | 6, 13 170 | 171 | 172 | Fill 173 | 174 | 175 | System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 176 | 177 | 178 | $this 179 | 180 | 181 | 0, 0 182 | 183 | 184 | 0 185 | 186 | 187 | 0 188 | 189 | 190 | LicenseInfoControl 191 | 192 | 193 | True 194 | 195 | --------------------------------------------------------------------------------