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

📄 framesystem.cs

📁 结构很好的三层数据访问组件。开放源码。是微软企业库数据访问的替代产品之一。
💻 CS
字号:
namespace FrameCountry.FrameBuild
{
    using FrameCountry;
    using Microsoft.Win32;
    using System;

    public class FrameSystem
    {
        private string ClassAlias = "SY";
        private FrameCity frameCity = new FrameCity();

        public bool DeleteRegeditInfo(string regeditKey, string regeditPath, string regeditParam, ref string ErrorInfo)
        {
            string functionAlias = "02";
            try
            {
                RegistryKey classesRoot;
                switch (regeditKey.ToLower())
                {
                    case "root":
                        classesRoot = Registry.ClassesRoot;
                        break;

                    case "user":
                        classesRoot = Registry.CurrentUser;
                        break;

                    case "machine":
                        classesRoot = Registry.LocalMachine;
                        break;

                    case "users":
                        classesRoot = Registry.Users;
                        break;

                    case "config":
                        classesRoot = Registry.CurrentConfig;
                        break;

                    default:
                        throw new Exception("请求的注册表根目录 " + regeditKey + " 不存在!");
                }
                if (regeditParam == "")
                {
                    classesRoot.DeleteSubKey(regeditPath);
                }
                else
                {
                    classesRoot.OpenSubKey(regeditPath, true).DeleteValue(regeditParam);
                }
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }

        public bool GetRegeditInfo(string regeditKey, string regeditPath, string regeditParam, ref string regeditValue, ref string ErrorInfo)
        {
            string functionAlias = "00";
            try
            {
                RegistryKey classesRoot;
                switch (regeditKey.ToLower())
                {
                    case "root":
                        classesRoot = Registry.ClassesRoot;
                        break;

                    case "user":
                        classesRoot = Registry.CurrentUser;
                        break;

                    case "machine":
                        classesRoot = Registry.LocalMachine;
                        break;

                    case "users":
                        classesRoot = Registry.Users;
                        break;

                    case "config":
                        classesRoot = Registry.CurrentConfig;
                        break;

                    default:
                        throw new Exception("请求的注册表根目录 " + regeditKey + " 不存在!");
                }
                classesRoot = classesRoot.OpenSubKey(regeditPath);
                regeditValue = classesRoot.GetValue(regeditParam).ToString();
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }

        public bool SetRegeditInfo(string regeditKey, string regeditPath, string regeditParam, string regeditValue, ref string ErrorInfo)
        {
            string functionAlias = "01";
            try
            {
                RegistryKey classesRoot;
                switch (regeditKey.ToLower())
                {
                    case "root":
                        classesRoot = Registry.ClassesRoot;
                        break;

                    case "user":
                        classesRoot = Registry.CurrentUser;
                        break;

                    case "machine":
                        classesRoot = Registry.LocalMachine;
                        break;

                    case "users":
                        classesRoot = Registry.Users;
                        break;

                    case "config":
                        classesRoot = Registry.CurrentConfig;
                        break;

                    default:
                        throw new Exception("请求的注册表根目录 " + regeditKey + " 不存在!");
                }
                classesRoot.CreateSubKey(regeditPath).SetValue(regeditParam, regeditValue);
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }
    }
}

⌨️ 快捷键说明

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