public static Object[] returnLicence() { string chemin = Chemins.getCheminInformation(); RegistryKey Nkey = Registry.CurrentUser; try { Object[] lic = new Object[3]; RegistryKey valKey = Nkey.OpenSubKey(@chemin, true); if (valKey != null) { lic[0] = (valKey.GetValue("authentify") != null ? valKey.GetValue("authentify") : false); lic[1] = (valKey.GetValue("licence") != null ? valKey.GetValue("licence") : ""); lic[2] = (valKey.GetValue("date_load") != null ? valKey.GetValue("date_load") : DateTime.Now); } return(lic); } catch (Exception e) { Messages.Exception(e); return(null); } finally { Nkey.Close(); } }
public static bool verifyKeyLicence(string key) { try { Object[] lic = returnLicence(); if (lic != null) { string valeur = Convert.ToString(lic[1]); var t = valeur + " = " + key; if (valeur.Trim().Equals(key.Trim())) { Constantes.ACTIVE = true; string chemin = Chemins.getCheminInformation(); RegistryKey Nkey = Registry.CurrentUser; try { RegistryKey valKey = Nkey.OpenSubKey(@chemin, true); if (valKey == null) { Nkey.CreateSubKey(@chemin); valKey = Nkey.OpenSubKey(@chemin, true); } valKey.SetValue("authentify", true); return(true); } catch (Exception e) { Messages.Exception(e); return(false); } finally { Nkey.Close(); } } } return(false); } catch (Exception e) { Messages.Exception(e); return(false); } }
public static void deleteLicence() { string chemin = Chemins.getCheminInformation(); RegistryKey Nkey = Registry.CurrentUser; try { RegistryKey valKey = Nkey.OpenSubKey(@chemin, true); if (valKey != null) { Nkey.DeleteSubKey(@chemin); } } catch (Exception e) { Messages.Exception(e); } finally { Nkey.Close(); } }
public static void createLicence() { string chemin = Chemins.getCheminInformation(); RegistryKey Nkey = Registry.CurrentUser; try { RegistryKey valKey = Nkey.OpenSubKey(@chemin, true); if (valKey == null) { Nkey.CreateSubKey(@chemin); valKey = Nkey.OpenSubKey(@chemin, true); valKey.SetValue("authentify", false); valKey.SetValue("licence", "696-668-969-694-234-044"); valKey.SetValue("date_load", DateTime.Now); } else { if ((valKey.GetValue("authentify") == null || valKey.GetValue("authentify").Equals("")) && (valKey.GetValue("licence") == null || valKey.GetValue("licence").Equals("")) && (valKey.GetValue("date_load") == null || valKey.GetValue("date_load").Equals(""))) { valKey.SetValue("authentify", false); valKey.SetValue("licence", "696-668-969-694-234-044"); valKey.SetValue("date_load", DateTime.Now); } } } catch (Exception e) { Messages.Exception(e); } finally { Nkey.Close(); } }