zoukankan      html  css  js  c++  java
  • .net 读写注册表

      /// <summary>
            /// 获得注册表中的信息
            /// </summary>
            /// <returns>返回注册表中网吧名称</returns>
            public string GetRegisterKey()
            {
                string reVal = "";
                RegistryKey softWareKey = Registry.CurrentUser.OpenSubKey("Software\\Test");

                if (softWareKey != null)
                {
                    object obj = softWareKey.GetValue("CompanyName");
                    reVal = obj.ToString();
                }

                return reVal;
               
            }

            /// <summary>
            /// 写注册表 将用户名称和网吧名称写入注册表
            /// </summary>
            /// <param name="userName">用户名称</param>
            /// <param name="lanBarName">网吧名称</param>
            /// <returns></returns>
            public int WriteRegisterKey(string userName, string lanBarName)
            {
                int iReturn = 1;

                try
                {
                    RegistryKey regWrite = Registry.CurrentUser.CreateSubKey("SoftWare\\Test");

                    regWrite.SetValue("CompanyName", lanBarName);

                    regWrite.SetValue("UserName", userName);

                    regWrite.Close();
                }
                catch (Exception ex)
                {
                    iReturn = 2;
                    throw ex;
                }
                return iReturn;
            }

  • 相关阅读:
    字幕文件srt处理之pysrt
    python 多进程代码问题以及用 pyinstaller 打包成exe 问题解决
    ffmpeg的安装以及使用
    人声识别之webrtcvad
    python3安装dlib库和face_recognition库
    python实现 请按任意键继续。。。
    python 模块tkinter之filedalog
    古诗文网验证码识别
    xpath案例-全国城市名爬取
    xpath案例-4K图片爬取
  • 原文地址:https://www.cnblogs.com/VirtualMJ/p/551747.html
Copyright © 2011-2022 走看看