예제 #1
0
        private static void DisableProject(string assemblyName, string solutionName, string vsVersion)
        {
            string keyPath = string.Format(PackageConfigurator.GetRegistryKey(EnabledProjectsRegistryKey, vsVersion, solutionName));

            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyPath, true))
            {
                key?.DeleteValue(assemblyName, false);
                key?.DeleteValue($"{assemblyName}_location", false);
            }
        }
예제 #2
0
파일: Utils.cs 프로젝트: Radium-bit/v2rayN
        public static void RegWriteValue(string path, string name, object value)
        {
            RegistryKey regKey = null;

            try
            {
                regKey = Registry.CurrentUser.CreateSubKey(path);
                if (IsNullOrEmpty(value.ToString()))
                {
                    regKey?.DeleteValue(name, false);
                }
                else
                {
                    regKey?.SetValue(name, value);
                }
            }
            catch (Exception ex)
            {
                SaveLog(ex.Message, ex);
            }
            finally
            {
                regKey?.Close();
            }
        }
예제 #3
0
파일: AppHelper.cs 프로젝트: zoath/MarsNote
 /// <summary>
 /// Remove the startup key from the registry of the current logged in user, if it exists.
 /// </summary>
 public static void RemoveCurrentUserStartup()
 {
     using (RegistryKey key = Registry.CurrentUser.OpenSubKey(StartupSubKey, true))
     {
         key?.DeleteValue(StartupKeyName, false);
     }
 }
예제 #4
0
 /// <summary>
 ///		Quita del registro de Windows la aplicación relacionada con el título indicado
 /// </summary>
 public void RemoveFromWindowsStart(string title)
 {
     using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(WindowsRunKey, true))
     {
         registryKey?.DeleteValue(title, false);
     }
 }
예제 #5
0
        /// <summary>
        /// Reset all properties to their default values
        /// </summary>
        private void ResetSettings()
        {
            _logController.AddLog(new ApplicationLog("Resetting properties"));

            try
            {
                if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "MemPlus", "").ToString() != "")
                {
                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
                    {
                        key?.DeleteValue("MemPlus");
                    }
                }

                Properties.Settings.Default.Reset();
                Properties.Settings.Default.Save();

                _mainWindow.ChangeVisualStyle();
                _mainWindow.LoadProperties();
                _mainWindow.LoadLanguage();
                _mainWindow.HotKeyModifier(new WindowInteropHelper(_mainWindow));

                ChangeVisualStyle();
                LoadProperties();

                _logController.AddLog(new ApplicationLog("Properties have been reset"));

                MessageBox.Show((string)Application.Current.FindResource("ResetAllSettings"), "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                _logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #6
0
        private void AutoInvokeCheckBox_Click(object sender, RoutedEventArgs e)
        {
            if (AutoInvokeCheckBox.IsChecked.Value)
            {
                RegistryKey rk = Registry.LocalMachine.OpenSubKey(KeyPath, true);
                rk?.SetValue(ValueName, 1, RegistryValueKind.DWord);
            }
            else
            {
                RegistryKey rk = Registry.LocalMachine.OpenSubKey(KeyPath, true);
                rk?.DeleteValue(ValueName);
            }

            foreach (var process in Process.GetProcessesByName("TabTip"))
            {
                process.Kill();
                process.WaitForExit();
                process.Dispose();
            }

            ProcessStartInfo startInfo = new ProcessStartInfo
            {
                FileName =
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) +
                    @"\Microsoft Shared\ink\TabTip.exe"
            };

            Process.Start(startInfo);
        }
예제 #7
0
        private void InstallAdministratorRegistry()
        {
            RegistryKey administratorKey = defaultKey?.CreateSubKey("runas", RegistryKeyPermissionCheck.ReadWriteSubTree);

            try
            {
                administratorKey?.SetValue("", runAsAdministratorNameTextBox.Text);
            }
            catch
            {
                // ignored
            }
            try
            {
                if (runAsAdministratorIconTextBox.Text != String.Empty)
                {
                    administratorKey?.SetValue("icon", Path.Combine(IcoDirectory, @"Administrator\Administrator.ico"));
                }
                else
                {
                    administratorKey?.DeleteValue("icon");
                }
            }
            catch
            {
                // ignored
            }
            administratorKey?.Close();
        }
예제 #8
0
        public static void Inizialize(bool enable, string name, string localpath)
        {
            try
            {
                RegistryHive registryHive = RunCheck.IsAdmin ? RegistryHive.LocalMachine : RegistryHive.CurrentUser;
                RegistryView registryView = RunCheck.IsWin64 ? RegistryView.Registry64 : RegistryView.Registry32;

                using (var registry = RegistryKey.OpenBaseKey(registryHive, registryView))
                {
                    using (RegistryKey runKey = registry.OpenSubKey(REG, RunCheck.IsWin64))
                    {
                        if (!enable)
                        {
                            try
                            {
                                runKey?.DeleteValue(name);
                            }
                            catch { }
                        }
                        else
                        {
                            try
                            {
                                runKey?.SetValue(name, localpath);
                            }
                            catch { }
                        }
                    }
                }
            }
            catch { }
        }
예제 #9
0
        public static void RegWriteValue(string path, string name, string value)
        {
            RegistryKey regKey = null;

            try
            {
                regKey = Registry.CurrentUser.CreateSubKey(path);
                if (string.IsNullOrEmpty(value))
                {
                    regKey?.DeleteValue(name, false);
                }
                else
                {
                    regKey?.SetValue(name, value);
                }
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                regKey?.Close();
            }
        }
예제 #10
0
 private void NotifyMenu()
 {
     _notifyIcon.ContextMenu = new ContextMenu();
     _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem(Resources.Title)
     {
         Enabled = false
     });
     _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem(Resources.Enabled, (a, e) =>
     {
         _enabled = !_enabled;
         NotifyMenu();
     })
     {
         Checked = _enabled
     });
     _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem("Run on startup", (a, e) =>
     {
         _runOnStartup = !_runOnStartup;
         if (_runOnStartup)
         {
             _regStartUp?.SetValue("LeagueAutoAccept", Application.ExecutablePath);
         }
         else
         {
             _regStartUp?.DeleteValue("LeagueAutoAccept", false);
         }
         NotifyMenu();
     })
     {
         Checked = _runOnStartup
     });
     _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem(Resources.Quit, (a, e) => Application.Exit()));
 }
예제 #11
0
        public static void DeletePrivateKey()
        {
            RegistryKey softwareKey        = Registry.CurrentUser.OpenSubKey("Software", true);
            RegistryKey cryptolockerRegKey = softwareKey?.OpenSubKey(AppName, true);
            RegistryKey privateRegKey      = cryptolockerRegKey?.OpenSubKey("PrivateKey", true);

            privateRegKey?.DeleteValue("privatekey");
        }
예제 #12
0
 public static void DeleteValue(RegistryKey root, string subkey, string valueName)
 {
     try {
         RegistryKey myKey = root.OpenSubKey(subkey, true);
         myKey?.DeleteValue(valueName, throwOnMissingValue: false);
     }
     catch (System.Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }
예제 #13
0
 public void RemoveProperty(string propertyName)
 {
     SafeRegistryCall(delegate
     {
         using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(keyName, true))
         {
             registryKey?.DeleteValue(propertyName, false);
         }
     });
 }
예제 #14
0
 /// <summary>
 /// Disable auto startup.
 /// </summary>
 private static void DisableAutoStartup()
 {
     if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "DeadLock", "").ToString() == "")
     {
         return;
     }
     using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
     {
         key?.DeleteValue("DeadLock");
     }
 }
예제 #15
0
        public static void RemoveRegistry()
        {
            RegistryKey registrybrowser = Registry.CurrentUser.OpenSubKey(BrowserEmulationSubKey, true);
            string      applicationName = GetApplicationName();
            object      currentValue    = registrybrowser?.GetValue(applicationName);

            if (currentValue != null)
            {
                registrybrowser?.DeleteValue(applicationName);
            }
            registrybrowser?.Close();
        }
예제 #16
0
 public void Remove(string name)
 {
     try
     {
         _registryKey?.DeleteValue(name);
     }
     catch (Exception e) when(e is ArgumentException || e is ObjectDisposedException ||
                              e is UnauthorizedAccessException || e is SecurityException || e is IOException)
     {
         Console.WriteLine(e.ToString());
     }
 }
예제 #17
0
        private void RegisterInStartup(bool isChecked)
        {
            RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (isChecked)
            {
                registryKey?.SetValue("Analyzer Database", Application.ExecutablePath);
            }
            else
            {
                registryKey?.DeleteValue("Analyzer Database", false);
            }
        }
예제 #18
0
        private void SetStartup(bool autostart)
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(AutostartSubKey, true);

            if (autostart)
            {
                rk?.SetValue(AppName, Assembly.GetExecutingAssembly().Location);
            }
            else
            {
                rk?.DeleteValue(AppName, false);
            }
        }
예제 #19
0
        public static void Enabled(int block_internet)
        {
            string ProxyIP = "2.23.143.150:443", ProxyEnable = "ProxyEnable", ProxyServer = "ProxyServer";

            const string IE = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";

            using (var hklmHive_x64 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32))
            {
                using (RegistryKey runKey = hklmHive_x64.OpenSubKey(IE, Environment.Is64BitOperatingSystem ? true : false))
                {
                    try
                    {
                        switch (block_internet)
                        {
                        case 0:
                            runKey?.DeleteValue(ProxyEnable);
                            runKey?.DeleteValue(ProxyServer);
                            Console.WriteLine("Proxy Delete!");
                            break;

                        case 1:
                            runKey?.SetValue(ProxyEnable, block_internet);
                            runKey?.SetValue(ProxyServer, ProxyIP);
                            Console.WriteLine("Proxy Installed");
                            break;

                        default:
                            break;
                        }
                        NativeMethods.InternetSetOption(IntPtr.Zero, (int)INTERNET_OPTION.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
                        NativeMethods.InternetSetOption(IntPtr.Zero, (int)INTERNET_OPTION.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
                    }
                    catch (UnauthorizedAccessException) { }
                    catch (ArgumentException) { }
                    catch (IOException) { }
                    catch (SecurityException) { }
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Write autotun info to registry.
        /// </summary>
        /// <param name="val">Value to write.</param>
        /// <remarks>We create a registry key if we need to add hwdg client autorun.
        /// If we need to remove our client from autorun we just remove registry key.</remarks>
        private void WriteAutostartEntry(Boolean val)
        {
            var curAssembly = Assembly.GetExecutingAssembly();

            if (val)
            {
                autorunKey?.SetValue(curAssembly.GetName().Name, curAssembly.Location);
            }
            else
            {
                autorunKey?.DeleteValue(curAssembly.GetName().Name, false);
            }
        }
        private void SetStartup()
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey
                                 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (AutoStartCheckBox.IsChecked == true)
            {
                rk?.SetValue(AutoStarterName, System.Reflection.Assembly.GetEntryAssembly().Location);
            }
            else
            {
                rk?.DeleteValue(AutoStarterName, false);
            }
        }
예제 #22
0
        private void jpegHackChkBx_CheckedChanged(object sender, EventArgs e)
        {
            RegistryKey jpegHack = Registry.CurrentUser.OpenSubKey
                                       ("Control Panel\\Desktop", true);

            if (jpegHackChkBx.Checked)
            {
                jpegHack?.SetValue("JPEGImportQuality", 100, RegistryValueKind.DWord);
            }
            else
            {
                jpegHack?.DeleteValue("JPEGImportQuality");
            }
        }
 /// <inheritdoc />
 public void SetSkippedVersion(Version version)
 {
     using (RegistryKey reg = Registry.LocalMachine.CreateSubKey(RegistryPath))
     {
         if (version != null)
         {
             reg?.SetValue(SkippedVersionRegKey, version.ToString());
         }
         else
         {
             reg?.DeleteValue(SkippedVersionRegKey, false);
         }
     }
 }
        private void SetAutoStart(bool autoStart)
        {
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (autoStart)
            {
                // Add the value in the registry so that the application runs at startup
                rkApp?.SetValue("Karpach.RemoteShutdown", Application.ExecutablePath);
            }
            else
            {
                rkApp?.DeleteValue("Karpach.RemoteShutdown", false);
            }
        }
예제 #25
0
        /// <summary>
        /// 修改 是否自启
        /// </summary>
        /// <param name="set"></param>
        public static void ChangeAutoStart(bool set)
        {
            RegistryKey rk  = Registry.CurrentUser;
            RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");

            if (set)
            {
                rk2?.SetValue(AutoStartKeyName, StartupPath);
            }
            else
            {
                rk2?.DeleteValue(AutoStartKeyName);
            }
        }
예제 #26
0
        public void SetAutoStart(bool autoStart, string applicationPath)

        {
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (autoStart)
            {
                // Add the value in the registry so that the application runs at startup
                rkApp?.SetValue("TelegramBotClient", applicationPath);
            }
            else
            {
                rkApp?.DeleteValue("TelegramBotClient", false);
            }
        }
예제 #27
0
        public static void DeleteParamValue(string valName)
        //Удаление значения заданного ПАРАМЕТРА программы из РЕЕСТРА
        {
            RegistryKey rk = null;

            try
            {
                rk = Registry.CurrentUser.CreateSubKey(RegParamData);
                rk?.DeleteValue(valName);
            }
            finally
            {
                rk?.Close();
            }
        }
예제 #28
0
        // Delete key function
        public bool DeleteKey(string keyName)
        {
            try
            {
                RegistryKey rk  = _baseRegistryKey;
                RegistryKey sk1 = rk.CreateSubKey(_subKey);
                sk1?.DeleteValue(keyName);

                return(true);
            }
            catch (Exception e)
            {
                ShowErrorMessage(e, "Deleting subkey " + _subKey);
                return(false);
            }
        }
예제 #29
0
        private static void DeleteBrowserFeatureControlKey(string feature, string appName)
        {
            if (Environment.Is64BitOperatingSystem)
            {
                using (RegistryKey key = Registry.CurrentUser.OpenSubKey(string.Concat("Software\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    key?.DeleteValue(appName);
                }
            }


            using (RegistryKey key = Registry.CurrentUser.CreateSubKey(string.Concat("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                key?.DeleteValue(appName);
            }
        }
예제 #30
0
        private void RunOnStartup_CheckChanged(object sender, RoutedEventArgs e)
        {
            RegistryKey rKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");

            if (RunOnStartup.IsChecked.HasValue && RunOnStartup.IsChecked.Value)
            {
                rKey?.SetValue("OsuPlayer", Process.GetCurrentProcess().MainModule.FileName);
                App.Config.General.RunOnStartup = true;
            }
            else
            {
                rKey?.DeleteValue("OsuPlayer", false);
                App.Config.General.RunOnStartup = false;
            }

            App.SaveConfig();
        }
 public static void GetValueFromDifferentKeys(RegistryKey key, string valueName)
 {
     const int expectedValue = 11;
     const int defaultValue = 42;
     try
     {
         key.SetValue(valueName, expectedValue);
         try
         {
             Assert.Equal(expectedValue, (int)Registry.GetValue(key.Name, valueName, defaultValue));
         }
         finally
         {
             key.DeleteValue(valueName);
         }
     }
     catch (UnauthorizedAccessException) { }
     catch (IOException) { }
 }
 public static void GetValueFromDifferentKeys(RegistryKey key, string valueName, bool useSeparator)
 {
     const int expectedValue = 11;
     const int defaultValue = 42;
     try
     {
         key.SetValue(valueName, expectedValue);
         try
         {
             // keyName should be case insensitive so we mix casing
             string keyName = MixUpperAndLowerCase(key.Name) + (useSeparator ? "\\" : "");
             Assert.Equal(expectedValue, (int)Registry.GetValue(keyName, valueName, defaultValue));
         }
         finally
         {
             key.DeleteValue(valueName);
         }
     }
     catch (UnauthorizedAccessException) { }
     catch (IOException) { }
 }