How to prevent reuse of deactivated keys
private void StoreDeactivatedKey(QlmLicense license, string computerKey)
{
try
{
// we will store the deactivated computerkey on the system and prevent the user from reusing it
bool userLevelResult;
ย bool machineLevelResult;
string errorMessage1;
string deactivatedKeys = string.Empty;
license.ReadCookie("DeactivatedKeys", 0, out deactivatedKeys);
ย if (!String.IsNullOrEmpty(deactivatedKeys))
{
deactivatedKeys += ";";
}
deactivatedKeys += this.computerKey.Replace("-", "").Trim ();
ย license.StoreCookie(deactivatedKeys, "DeactivatedKeys", 0, out userLevelResult, out machineLevelResult, out errorMessage1);
}
catch { }
}
private bool IsDeactivatedKey (QlmLicense license, string newkey)
{
try
{
newkey = newkey.Replace("-", "").Trim ();
// Check if this is a deactivated key
string deactivatedKeys;
license.ReadCookie("DeactivatedKeys", 0, out deactivatedKeys);
ย if (!String.IsNullOrEmpty(deactivatedKeys))
{
char[] sep = { ';' };
string[] keys = deactivatedKeys.Split(sep, StringSplitOptions.RemoveEmptyEntries);
foreach (string key in keys)
{
if (String.Compare(key, newkey, true) == 0)
{
return true;
}
}
}
}
catch { }
ย return false;
}PreviousWhy does ReadKeys return the wrong keyNextHow to recover from a corrupted xml configuration file
Last updated