### IntelliLock command line example combinations Source: https://www.eziriz.com/intellilock_online_help/source/command_line/index.html A batch of example command lines showing how to invoke INTELLILOCK.exe with various options. Includes examples for protecting a single file, specifying a destination, using a project file, disabling obfuscation, quiet mode, multiple files, exclude options, and expiration settings. ```batch INTELLILOCK.exe -file "c:\testapp.exe" INTELLILOCK.exe -file "c:\testlib.dll" -destination "c:\test\testlib.dll" INTELLILOCK.exe -project "c:\myproject.ilproj" -obfuscation 0 INTELLILOCK.exe -file "c:\testapp.exe" -project "c:\myproject.ilpro" INTELLILOCK.exe -file "c:\testapp.exe" -project "c:\myproject.ilproj" -q INTELLILOCK.exe -file "c:\mainapp.exe" - file "c:\mylib1.dll" - file "c:\mylib2.dll" INTELLILOCK.exe -file "c:\mainapp.exe" - file "c:\mylib1.dll" exlcude 1 - file "c:\mylib2.dll" - exlucde 0 INTELLILOCK.exe -file "c:\testapp.exe" -expirationdays 1 -expirationdays_value 28 -dialog_nag 1 ``` -------------------------------- ### Install Eziriz.IntelliLock.TrimHelper via dotnet CLI Source: https://www.eziriz.com/intellilock_online_help/source/troubleshooting/trimming/index.html Run this command in the project that is being trimmed to install the Eziriz.IntelliLock.TrimHelper NuGet package. This resolves trimming issues by ensuring required elements are not removed. ```bash dotnet add package Eziriz.IntelliLock.TrimHelper ``` -------------------------------- ### Check license status asynchronously with LicenseCheckFinished event Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html This example shows how to check the license asynchronously to avoid startup delays. It requires the 'Asynchronous License Check' option to be enabled in IntelliLock. The event handler prints the hardware ID and license status. ```csharp /*** Check the license. ***/ class Program { // To automatically check the license asynchronously the option "Asynchronous License Check" must be enabled in IntelliLock static void Main(string[] args) { IntelliLock.Licensing.EvaluationMonitor.LicenseCheckFinished += () => { Console.WriteLine(IntelliLock.Licensing.HardwareID.GetHardwareID(false, true, false, true, true, false)); Console.WriteLine(IntelliLock.Licensing.CurrentLicense.LicenseStatus.ToString()); }; Console.ReadLine(); } } ``` -------------------------------- ### Reference IntelliLock.Licensing namespace Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Adds the using directive for the IntelliLock.Licensing namespace, required for all other licensing examples. ```csharp using IntelliLock.Licensing; ``` -------------------------------- ### Create License File (byte array) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a license file and returns it as a byte array. Adds a license information key-value pair before generating. ```csharp /// /// Create License File /// public byte[] CreateLicenseFile(string proj_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); return IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject); } ``` -------------------------------- ### Get Hardware ID of current machine Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Returns the Hardware ID of the current machine using the HardwareID.GetHardwareID method with the specified parameters. ```csharp /*** Get Hardware ID of the current machine ***/ public string GetHardwareID() { return HardwareID.GetHardwareID(true, true, false, true, true, false); } ``` -------------------------------- ### Asynchronous License Check Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Demonstrates how to check the license status asynchronously to prevent startup delays, using the LicenseCheckFinished event. ```APIDOC ## Asynchronous License Check ### Description Demonstrates how to check the license status asynchronously to prevent startup delays. Requires the "Asynchronous License Check" option to be enabled in IntelliLock. ### Usage Subscribe to the `IntelliLock.Licensing.EvaluationMonitor.LicenseCheckFinished` event to receive notification when the license check completes. The event handler can then access the hardware ID and license status. ### Example 1: Automatic Asynchronous Check ```csharp class Program { // To automatically check the license asynchronously the option "Asynchronous License Check" must be enabled in IntelliLock static void Main(string[] args) { IntelliLock.Licensing.EvaluationMonitor.LicenseCheckFinished += () => { Console.WriteLine(IntelliLock.Licensing.HardwareID.GetHardwareID(false, true, false, true, true, false)); Console.WriteLine(IntelliLock.Licensing.CurrentLicense.LicenseStatus.ToString()); }; Console.ReadLine(); } } ``` ### Example 2: Manual Asynchronous Load and Check ```csharp class Program { // To automatically check the license asynchronously the option "Asynchronous License Check" must be enabled in IntelliLock static void Main(string[] args) { string licenseFile = @"C:\license.license"; // To ensure SDK method calls doesn't block/delay the control flow the SDK method LoadLicense(...) should be run in asynchronous context (new Action()..) as well new Action(() => { IntelliLock.Licensing.EvaluationMonitor.LoadLicense(File.ReadAllBytes(licenseFile)); IntelliLock.Licensing.EvaluationMonitor.LicenseCheckFinished += () => { Console.WriteLine(IntelliLock.Licensing.HardwareID.GetHardwareID(false, true, false, true, true, false)); Console.WriteLine(IntelliLock.Licensing.CurrentLicense.LicenseStatus.ToString()); }; }).BeginInvoke(null, null); Console.WriteLine("Due to asynchronous control flow this line is displayed first"); Console.ReadLine(); } } ``` ``` -------------------------------- ### Get loaded license as byte array with GetLicense Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Retrieves the currently loaded license as a byte array using EvaluationMonitor.GetCurrentLicenseAsByteArray(). Returns null if no license is loaded. ```csharp /*** Get the license. ***/ public byte[] GetLicense() { return EvaluationMonitor.GetCurrentLicenseAsByteArray(); } ``` -------------------------------- ### Open IntelliLock Project File Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a ProjectFile object from a project filename. This is the first step for most license operations. ```csharp /// /// Open IntelliLock Project /// public IntelliLock.LicenseManager.ProjectFile ReadProjectFile(string proj_filename) { return new IntelliLock.LicenseManager.ProjectFile(proj_filename); } ``` -------------------------------- ### Check Hardware Lock status and get Hardware ID Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Checks whether the Hardware Lock is enabled and, if so, retrieves the Hardware ID stored in the license file. ```csharp /*** Check the license status of Hardware Lock ***/ public void CheckHardwareLock() { bool lock_enabled = EvaluationMonitor.CurrentLicense.HardwareLock_Enabled; if (lock_enabled) { /* Get Hardware ID stored in the license file */ string lic_hardware_id = EvaluationMonitor.CurrentLicense.HardwareID; } } ``` -------------------------------- ### Create License File (to file) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a license file and writes it to the specified filename. Adds a license information key-value pair before generating. ```csharp /// /// Create License File /// public void CreateLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject, license_filename); } ``` -------------------------------- ### CreateLicenseFile (byte[] overload) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a license file from a project file and returns it as a byte array. ```APIDOC ## CreateLicenseFile (byte[] overload) ### Description Creates a license file from a project file and returns it as a byte array. ### Method CreateLicenseFile ### Signature public byte[] CreateLicenseFile(string proj_filename) ### Parameters - **proj_filename** (string) - Required - The path to the IntelliLock project file. ### Returns - **byte[]** - The generated license file as a byte array. ### Example ```csharp public byte[] CreateLicenseFile(string proj_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); return IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject); } ``` ``` -------------------------------- ### CreateLicenseFile (void overload) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a license file and saves it to a specified file path. ```APIDOC ## CreateLicenseFile (void overload) ### Description Creates a license file and saves it to a specified file path. ### Method CreateLicenseFile ### Signature public void CreateLicenseFile(string proj_filename, string license_filename) ### Parameters - **proj_filename** (string) - Required - The path to the IntelliLock project file. - **license_filename** (string) - Required - The path where the license file will be saved. ### Returns - **void** - This method does not return a value. ### Example ```csharp public void CreateLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject, license_filename); } ``` ``` -------------------------------- ### CreateHardwareLockedLicenseFile Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a hardware-locked license file with specified hardware lock settings. ```APIDOC ## CreateHardwareLockedLicenseFile ### Description Creates a hardware-locked license file with specified hardware lock settings. ### Method CreateLicenseFile ### Signature public void CreateLicenseFile(string proj_filename, string license_filename) ### Parameters - **proj_filename** (string) - Required - The path to the IntelliLock project file. - **license_filename** (string) - Required - The path where the license file will be saved. ### Hardware Lock Settings - **HardwareLock_Enabled** (bool) - Required - Enables hardware locking. - **HardwareLock_BIOS** (bool) - Required - Locks to BIOS. - **HardwareLock_CPU** (bool) - Required - Locks to CPU. - **HardwareLock_HDD** (bool) - Required - Locks to HDD. - **HardwareLock_MAC** (bool) - Required - Locks to MAC address. - **HardwareLock_Mainboard** (bool) - Required - Locks to mainboard. - **HardwareLock_OS** (bool) - Required - Locks to OS. - **Hardware_ID** (string) - Required - The hardware ID to lock to. ### Returns - **void** - This method does not return a value. ### Example ```csharp public void CreateLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); myproject.HardwareLock_Enabled = true; myproject.HardwareLock_BIOS = true; myproject.HardwareLock_CPU = true; myproject.HardwareLock_HDD = true; myproject.HardwareLock_MAC = false; myproject.HardwareLock_Mainboard = true; myproject.HardwareLock_OS = false; myproject.Hardware_ID = "B745-C55C-1B94-6250-E98E-9BA0"; IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject, license_filename); } ``` ``` -------------------------------- ### Read License File (from file) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Reads a license file from a filename and returns the ProjectFile object. ```csharp /// /// Read License File /// public IntelliLock.LicenseManager.ProjectFile ReadLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); return myproject.ReadLicenseFile(license_filename); } ``` -------------------------------- ### OpenDatabase - Open an IntelliLock database Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_deobfuscator/index.html Creates and returns an IntelliLockDB.ILDataBase instance using the provided database filename and password. This is the first step for any database operation. ```csharp /// /// Open Database /// public IntelliLockDB.ILDataBase OpenDatabase(string db_filename, string db_password) { return new IntelliLockDB.ILDataBase(db_filename, db_password); } ``` -------------------------------- ### Manually load a license using a filename with LoadLicense Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Loads a license from a file path using the EvaluationMonitor. The filename is passed as a string. ```csharp /*** Load the license. ***/ public void LoadLicense(string filename) { EvaluationMonitor.LoadLicense(filename); } ``` -------------------------------- ### Import Sales from XML using IntelliLockDB.ILDataBase Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_deobfuscator/index.html Instantiates the database, records the current sale count, imports sales from an XML string using FromXml, saves the changes, and then records the new sale count. ```csharp /// /// Import Sales From XML /// public void SalesToXML(string db_filename, string db_password, string xml) { IntelliLockDB.ILDataBase mydb = new IntelliLockDB.ILDataBase(db_filename, db_password); int salesbefore = mydb.Sales.SaleCount; mydb.Sales.FromXml(xml); mydb.Sales.Save(); int salesafter = mydb.Sales.SaleCount; } ``` -------------------------------- ### AddCustomer - Add a customer to the database Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_deobfuscator/index.html Adds a new customer to the IntelliLock database using the Customers.AddCustomer() method, sets customer properties, and saves the changes. ```csharp /// /// Add Customer /// public void AddCustomer(string db_filename, string db_password) { IntelliLockDB.ILDataBase mydb = new IntelliLockDB.ILDataBase(db_filename, db_password); IntelliLockDB.Customer customer = mydb.Customers.AddCustomer(); customer.Company = "ACME"; customer.FirstName = "John"; customer.LastName = "Doe"; customer.EMail = "mymail@mydomain.com"; mydb.Customers.Save(); } ``` -------------------------------- ### Create Hardware Locked License File Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Creates a hardware-locked license file by enabling hardware lock options (BIOS, CPU, HDD, Mainboard) and setting a hardware ID. ```csharp /// /// Create Hardware Locked License File /// public void CreateLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); myproject.LicenseInformation.Add("MyKey", "MyValue"); myproject.HardwareLock_Enabled = true; myproject.HardwareLock_BIOS = true; myproject.HardwareLock_CPU = true; myproject.HardwareLock_HDD = true; myproject.HardwareLock_MAC = false; myproject.HardwareLock_Mainboard = true; myproject.HardwareLock_OS = false; myproject.Hardware_ID = "B745-C55C-1B94-6250-E98E-9BA0"; IntelliLock.LicenseManager.LicenseGenerator.CreateLicenseFile(myproject, license_filename); } ``` -------------------------------- ### Compare current Hardware ID with license file Hardware ID Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Compares the Hardware ID of the current machine with the Hardware ID stored in the license file and returns true if they match, otherwise false. ```csharp /*** Compare current Hardware ID with Hardware ID stored in License File ***/ public bool CompareHardwareID() { if (HardwareID.GetHardwareID(true, true, false, true, true, false) == EvaluationMonitor.CurrentLicense.HardwareID) return true; else return false; } ``` -------------------------------- ### Manually load a license using byte array with LoadLicense Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Loads a license from a byte array using the EvaluationMonitor. The license data is passed as a byte[]. ```csharp /*** Load the license. ***/ public void LoadLicense(byte[] license) { EvaluationMonitor.LoadLicense(license); } ``` -------------------------------- ### Read License File (from byte array) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Reads a license file from a byte array and returns the ProjectFile object. ```csharp /// /// Read License File /// public IntelliLock.LicenseManager.ProjectFile ReadLicenseFile(string proj_filename, byte[] license) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); return myproject.ReadLicenseFile(license); } ``` -------------------------------- ### Check license status asynchronously with manual load and BeginInvoke Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Alternative asynchronous license check that manually loads a license file and uses BeginInvoke to avoid blocking. The 'Asynchronous License Check' option must be enabled. The event handler prints hardware ID and license status after loading. ```csharp /*** Check the license. ***/ class Program { // To automatically check the license asynchronously the option "Asynchronous License Check" must be enabled in IntelliLock static void Main(string[] args) { string licenseFile = @"C:\license.license"; // To ensure SDK method calls doesn't block/delay the control flow the SDK method LoadLicense(...) should be run in asynchronous context (new Action()..) as well new Action(() => { IntelliLock.Licensing.EvaluationMonitor.LoadLicense(File.ReadAllBytes(licenseFile)); IntelliLock.Licensing.EvaluationMonitor.LicenseCheckFinished += () => { Console.WriteLine(IntelliLock.Licensing.HardwareID.GetHardwareID(false, true, false, true, true, false)); Console.WriteLine(IntelliLock.Licensing.CurrentLicense.LicenseStatus.ToString()); }; }).BeginInvoke(null, null); Console.WriteLine("Due to asynchronous control flow this line is displayed first"); Console.ReadLine(); } ``` -------------------------------- ### CompareHardwareID Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_license/index.html Compares the current machine's Hardware ID with the Hardware ID stored in the license file and returns true if they match, otherwise false. ```APIDOC ## CompareHardwareID ### Description Compares the current machine's Hardware ID with the Hardware ID stored in the license file and returns true if they match, otherwise false. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters None ### Request Example N/A ### Response Returns a boolean indicating whether the Hardware IDs match. ### Code Example ```csharp /*** Compare current Hardware ID with Hardware ID stored in License File ***/ public bool CompareHardwareID() { if (HardwareID.GetHardwareID(true, true, false, true, true, false) == EvaluationMonitor.CurrentLicense.HardwareID) return true; else return false; } ``` ``` -------------------------------- ### Export Sales to XML using IntelliLockDB.ILDataBase Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_deobfuscator/index.html Creates an IntelliLockDB.ILDataBase instance with the provided filename and password, then calls ToXml() on the Sales collection to export sales data to XML. ```csharp /// /// Export Sales To XML /// public void ExportSalesToXML(string db_filename, string db_password) { IntelliLockDB.ILDataBase mydb = new IntelliLockDB.ILDataBase(db_filename, db_password); mydb.Sales.ToXml(); } ``` -------------------------------- ### ReadLicenseFile (string overload) Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Reads a license file from a file path and returns the project file with license information. ```APIDOC ## ReadLicenseFile (string overload) ### Description Reads a license file from a file path and returns the project file with license information. ### Method ReadLicenseFile ### Signature public IntelliLock.LicenseManager.ProjectFile ReadLicenseFile(string proj_filename, string license_filename) ### Parameters - **proj_filename** (string) - Required - The path to the IntelliLock project file. - **license_filename** (string) - Required - The path to the license file to read. ### Returns - **IntelliLock.LicenseManager.ProjectFile** - The project file with license information. ### Example ```csharp public IntelliLock.LicenseManager.ProjectFile ReadLicenseFile(string proj_filename, string license_filename) { IntelliLock.LicenseManager.ProjectFile myproject = new IntelliLock.LicenseManager.ProjectFile(proj_filename); return myproject.ReadLicenseFile(license_filename); } ``` ``` -------------------------------- ### ReadProjectFile Source: https://www.eziriz.com/intellilock_online_help/source/sdk/sdk_wrapper/index.html Opens an IntelliLock project file and returns a ProjectFile object. ```APIDOC ## ReadProjectFile ### Description Opens an IntelliLock project file and returns a ProjectFile object. ### Method ReadProjectFile ### Signature public IntelliLock.LicenseManager.ProjectFile ReadProjectFile(string proj_filename) ### Parameters - **proj_filename** (string) - Required - The path to the IntelliLock project file. ### Returns - **IntelliLock.LicenseManager.ProjectFile** - The opened project file. ### Example ```csharp public IntelliLock.LicenseManager.ProjectFile ReadProjectFile(string proj_filename) { return new IntelliLock.LicenseManager.ProjectFile(proj_filename); } ``` ```