⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registryhelper.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Utils
{
    using Microsoft.Win32;
    using System;

    public static class RegistryHelper
    {
        private const string KeyPath = @"Software\Microsoft\Windows\CurrentVersion\Run";

        public static bool IsAppStartUp(string appName, string appPath)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            if (key == null)
            {
                return false;
            }
            object obj2 = key.GetValue(appName);
            return string.Equals(appPath, obj2 as string, 1);
        }

        public static RegistryKey OpenOrCreateSubKey(RegistryKey rkParent, string keyPath)
        {
            RegistryKey key = rkParent;
            RegistryKey key2 = null;
            try
            {
                int startIndex = 0;
                while (startIndex < keyPath.Length)
                {
                    int index = keyPath.IndexOf('\\', startIndex);
                    if (index < 0)
                    {
                        index = keyPath.Length;
                    }
                    string text = keyPath.Substring(startIndex, index - startIndex);
                    if (text.Length <= 0)
                    {
                        throw new ArgumentException("Invalid keyPath - " + keyPath);
                    }
                    startIndex = index + 1;
                    key2 = key.OpenSubKey(text, 2, 0x20006);
                    if (key2 == null)
                    {
                        key2 = key.CreateSubKey(text, 2);
                    }
                    key = key2;
                }
                return key2;
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static bool RegStartUp(string appName, string appPath)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            if (key == null)
            {
                return false;
            }
            key.SetValue(appName, appPath, 1);
            return true;
        }

        public static bool UnregStartUp(string appName)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            if (key == null)
            {
                return false;
            }
            key.DeleteValue(appName, false);
            return true;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -