//PRIVATE SHARED private static void LoadSettings() { RegistryKey TmpKey; RegistryKey TmpRegRoot; string TmpS; try { //get the Registry-Key TmpRegRoot = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, ""); TmpKey = TmpRegRoot.OpenSubKey(cRegistryPath, true); if (!TmpKey == null) { //Key exists //load FCurrentRefactoryProvider TmpS = TmpKey.GetValue("CurrentRefactoryProvider", ""); if (TmpS != "") { FCurrentRefactoryProvider = Activator.CreateInstance(Type.GetType(TmpS)); } //load FAutoCloseStatusDialogs TmpS = TmpKey.GetValue("AutoCloseStatusDialogs", "0"); FAutoCloseStatusDialogs = (TmpS == "1"); //load FAutoUpdateOnNewVersion TmpS = TmpKey.GetValue("AutoUpdateOnNewVersion", "1"); FAutoUpdateOnNewVersion = (TmpS == "1"); //close Key TmpKey.Close(); } //close Registry TmpRegRoot.Close(); } catch (Exception ex) { } //load default FCurrentRefactoryProvider if (FCurrentRefactoryProvider == null) { FCurrentRefactoryProvider = RefactoryNet20Provider.Instance; } //settings loaded ok FSettingsLoaded = true; }
private static void SaveSettings() { RegistryKey TmpKey; RegistryKey TmpRegRoot; try { //get the Registry-Key TmpRegRoot = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, ""); TmpKey = TmpRegRoot.OpenSubKey(cRegistryPath, true); if (TmpKey == null) { //Key not exists, create TmpKey = TmpRegRoot.CreateSubKey(cRegistryPath); } //save FCurrentRefactoryProvider TmpKey.SetValue("CurrentRefactoryProvider", ((object)FCurrentRefactoryProvider).GetType.FullName); //save FAutoCloseStatusDialogs if (FAutoCloseStatusDialogs) { TmpKey.SetValue("AutoCloseStatusDialogs", "1"); } else { TmpKey.SetValue("AutoCloseStatusDialogs", "0"); } //save FAutoCloseStatusDialogs if (FAutoUpdateOnNewVersion) { TmpKey.SetValue("AutoUpdateOnNewVersion", "1"); } else { TmpKey.SetValue("AutoUpdateOnNewVersion", "0"); } //close Key+Registry TmpKey.Close(); TmpRegRoot.Close(); } catch (Exception ex) { } }