Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 /// <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");
     }
 }
Esempio n. 3
0
 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("");
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 /// <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");
     }
 }
Esempio n. 7
0
 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>());
     }
 }
Esempio n. 8
0
        private void UpdateDataFromRegistryButton_Click(object sender, EventArgs e)
        {
            RegistryWorker registryWorker = new RegistryWorker();

            registryWorker.SetData(OpenKeyTextBox.Text, SecretKeyTextBox.Text, RestApiTextBox.Text);
        }
Esempio n. 9
0
        private void AddDataToRegistry_Click(object sender, EventArgs e)
        {
            RegistryWorker registryWorker = new RegistryWorker();

            registryWorker.RegisterKeyApi(OpenKeyTextBox.Text, SecretKeyTextBox.Text, RestApiTextBox.Text);
        }
Esempio n. 10
0
 public void RegistryWorkerTestInitialise()
 {
     registryWorker = new RegistryWorker();
     path           = registryWorker.GetPath();
 }