private void GetDataFromRegistry() { RegistryWorker registryWorker = new RegistryWorker(); string[] vs = registryWorker.GetData(); OpenKeyTextBox.Text = vs[0].ToString(); SecretKeyTextBox.Text = vs[1].ToString(); RestApiTextBox.Text = vs[2].ToString(); }
/// <summary> /// /// </summary> /// <param name="lastValue"></param> /// <param name="valueName"></param> /// <param name="keyLocation"></param> /// <param name="saveValue"></param> internal static void SaveRegistrySettings(string valueName, string keyLocation, string saveValue) { if (RegistryWorker.WriteKeyValue(Microsoft.Win32.RegistryHive.LocalMachine, keyLocation, Microsoft.Win32.RegistryValueKind.String, valueName, saveValue)) { return; } else { throw new Exception("UNABLE TO USE REGKEY HKEY_LOCAL_MACHINE\\" + keyLocation + "\\" + valueName + " PLEASE TRY TO RUN PROGRAM WITH ADMIN RIGHTS"); } }
private string GetSavedPassword(string location) { try { return(RegistryWorker.GetKeyValue <string>(Microsoft.Win32.RegistryHive.LocalMachine, location, Consts._PASSWORD)); } catch (Exception ex) { _log.Error(ex.Message); return(""); } }
private bool CreateProfilesListValue() { try { return(RegistryWorker.WriteKeyValue(Microsoft.Win32.RegistryHive.LocalMachine, Consts._SETTINGS_LOCATION + "\\" + Consts._PROFILES_LOCATION, Microsoft.Win32.RegistryValueKind.MultiString, Consts._PROFILESLIST, new string[] { })); } catch (Exception ex) { _log.Error(ex.Message); return(false); } }
private bool CreateProfilesKey() { try { return(RegistryWorker.CreateSubKey(Microsoft.Win32.RegistryHive.LocalMachine, Consts._SETTINGS_LOCATION + "\\" + Consts._PROFILES_LOCATION)); } catch (Exception ex) { _log.Error(ex.Message); return(false); } }
/// <summary> /// /// </summary> /// <param name="keyValue"></param> /// <param name="valueName"></param> /// <param name="keyLocation"></param> /// <param name="defaulttValue"></param> internal static void CheckRegistrySettings(ref string keyValue, string valueName, string keyLocation, string defaulttValue) { if (RegistryWorker.GetKeyValue <string>(Microsoft.Win32.RegistryHive.LocalMachine, keyLocation, valueName) != null) { keyValue = RegistryWorker.GetKeyValue <string>(Microsoft.Win32.RegistryHive.LocalMachine, keyLocation, valueName); } else if (RegistryWorker.WriteKeyValue(Microsoft.Win32.RegistryHive.LocalMachine, keyLocation, Microsoft.Win32.RegistryValueKind.String, valueName, defaulttValue)) { keyValue = defaulttValue; } else { throw new Exception("UNABLE TO USE REGKEY HKEY_LOCAL_MACHINE\\" + keyLocation + "\\" + valueName + " PLEASE TRY TO RUN PROGRAM WITH ADMIN RIGHTS"); } }
private List <string> GetSavedProfiles() { try { return(RegistryWorker.GetKeyValue <string[]>(Microsoft.Win32.RegistryHive.LocalMachine, Consts._SETTINGS_LOCATION + "\\" + Consts._PROFILES_LOCATION, Consts._PROFILESLIST).ToList()); } catch (System.IO.IOException ex) { _log.Error(ex.Message); if (CreateProfilesKey()) { return(GetSavedProfiles()); } else { return(new List <string>()); } } catch (ArgumentNullException ex) { _log.Error(ex.Message); if (CreateProfilesListValue()) { return(GetSavedProfiles()); } else { return(new List <string>()); } } catch (Exception ex) { _log.Error(ex.Message); return(new List <string>()); } }
private void UpdateDataFromRegistryButton_Click(object sender, EventArgs e) { RegistryWorker registryWorker = new RegistryWorker(); registryWorker.SetData(OpenKeyTextBox.Text, SecretKeyTextBox.Text, RestApiTextBox.Text); }
private void AddDataToRegistry_Click(object sender, EventArgs e) { RegistryWorker registryWorker = new RegistryWorker(); registryWorker.RegisterKeyApi(OpenKeyTextBox.Text, SecretKeyTextBox.Text, RestApiTextBox.Text); }
public void RegistryWorkerTestInitialise() { registryWorker = new RegistryWorker(); path = registryWorker.GetPath(); }