License validation
Learn how you can check if a given license feature is present on a users PC.
Use this procedure to check the availablility and expirey date of a license feature.
Check for the license based on the feature provided and display appropriate message.
Get license information.
Solution
string licenseExpirationDate = string.Empty; string feature = "Myfeature"; //AcquireLicense bool result = LicenseValidator.AcquireLicense(feature, LicenseHoldType.AllowRelease); if (result == false) { Logger.AddMessage(new LogMessage("Invalid License")); }//Get license expiration date LicenseInformation info; bool ret = LicenseValidator.GetLicenseInformation(feature, out info); if (ret == true) { licenseExpirationDate = info.ExpirationDate.ToShortDateString(); }
Example
This example provides information to check for license.
private static bool ValidateLicense()
{
string licenseExpirationDate = string.Empty;
string feature = "Myfeature";
//AcquireLicense
bool result = LicenseValidator.AcquireLicense(feature, LicenseHoldType.AllowRelease);
if (result == false)
{
Logger.AddMessage(new LogMessage("Invalid License"));
}
//Get license expiration date
LicenseInformation info;
bool ret = LicenseValidator.GetLicenseInformation(feature, out info);
if (ret == true)
{
licenseExpirationDate = info.ExpirationDate.ToShortDateString();
}
return result;
}