zoukankan      html  css  js  c++  java
  • 向注册表中写东西

    /// <summary>
    /// 将记录的功能名称写入注册表 by vichin 2016.5.17
    /// </summary>
    /// <param name="functionNode"></param>
    public void SetReg(string functionNode) {
    RegistryKey key = Registry.LocalMachine;
    RegistryKey portal = key.CreateSubKey("SOFTWARE\PICS\PORTAL");
    portal.SetValue("PORTAL", functionNode);
    portal.Close();
    } 

    这当中的地址,必须要有一个计算机生成的绝对地址,不能单单的写入由用户生成的地址

    开始写了pics\portal,然并卵,后面加入了software就有用了,这software便是计算机中原本拥有的地址。

      

    //将字符串从注册表中读取出来。
    RegSetandRead RSR = new RegSetandRead();
    string functionNode = string.Empty;
    int i=0;
    if (RSR.Exist(ref functionNode,ref i))
    {
    showLayout(functionNode,i); 
    }
    
    public class RegSetandRead
    {
    /// <summary>
    /// 从注册表中找出用户上次退出的节点。 by vichin 2016.5.16
    /// </summary>
    /// <param name="functionNode"></param>
    /// <returns></returns>
    public bool Exist(ref string nodeName, ref int i)
    {
    
    RegistryKey pics = Registry.LocalMachine.OpenSubKey("SOFTWARE\PICS\PORTAL");
    if (pics == null) 
    return false; 
    else
    {
    string functionNode = pics.GetValue("PORTAL").ToString();
    string[] nameIndex = functionNode.Split(',');
    nodeName = nameIndex[0];
    int.TryParse(nameIndex[1], out i);
    pics.Close();
    return true;
    }
    }
    /// <summary>
    /// 将记录的功能名称写入注册表 by vichin 2016.5.17
    /// </summary>
    /// <param name="functionNode"></param>
    public void SetReg(string functionNode)
    {
    RegistryKey key = Registry.LocalMachine;
    RegistryKey portal = key.CreateSubKey("SOFTWARE\PICS\PORTAL");
    portal.SetValue("PORTAL", functionNode);
    portal.Close();
    }
    }
  • 相关阅读:
    Python3 使用requests库读取本地保存的cookie文件实现免登录访问
    Python3 使用requests库登陆知乎并保存cookie为本地文件
    python中的ConfigParser模块
    python中json的使用
    python中的IO模块
    python中的apscheduler模块
    ubuntu14静态ip配置
    在ubuntu14中搭建邮箱服务器
    python 生成器
    python中列表生成式
  • 原文地址:https://www.cnblogs.com/vichin/p/5501409.html
Copyright © 2011-2022 走看看