• C# 操作注册表


    C#中对注册表的操作用类Registry.RegistryKey实现。

    其中

    1、创建注册表:CreateSubKey , SetValue;

    2、删除注册表:DeleteSubKey,DeleteSubKeyTree , DeleteValue

    3、获取注册表:OpenSubKey , GetValue

    用注册表可以实现很多的需求:比如说记录是不是第一次打开该软件:

    我们就可以用一个注册表来实现;

    public static bool IsFirstTimeLaunch()
            {
                RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(Strings.RegBasePath);
                string a = (string)registryKey.GetValue("FirstTimeLaunch", "");
                if (a == "")
                {
                    registryKey.SetValue("FirstTimeLaunch", DateTime.Now.ToString());
                }
                return a == "";
            }

    当然用注册表还可以去记录一些其他的许许多多的信息,具体看你的需求啦!

  • 相关阅读:
    mysql日志
    验证栈序列
    限流方案分析
    集合
    数据结构-树
    链表的中间节点
    PHP实现链表
    php扩展安装方式
    2017 Multi-University Training Contest
    用LCT解一类动态图的问题
  • 原文地址:https://www.cnblogs.com/shaozhuyong/p/6021843.html
Copyright © 2020-2023  润新知