• C#检验注册表中的某一注册表项的值


    using System;
    using System.Windows.Forms;
    using Microsoft.Win32;
    
    private static string GetVersionInfo()
            {
                string result = null;
                RegistryKey key;
                try
                {
                    key = Registry.LocalMachine.OpenSubKey(Define.ProductVersionPath);
                    if(key != null)
                    {
                        object o = key.GetValue(Define.VersionSign);
                        return o.ToString();
                    }
                }
                catch(Exception e)
                {
                    Helper.Write(e.ToString());
                }
                return result;
            }

    其中:Registry静态类提供表示 Windows 注册表中的根项的 Microsoft.Win32.RegistryKey 对象,并提供访问项/值对的 static 方法。

    RegistryKey类表示 Windows 注册表中的项级节点。此类sealed,不可继承。

    object GetValue(string name):检索与指定名称关联的值。如果注册表中不存在名称/值对,则返回 null。

    RegistryKey OpenSubKey(string name):以只读方式检索子项。

  • 相关阅读:
    Arrays类
    异常
    Java日志第53天 2020.8.29
    Java日志第52天 2020.8.28
    Java日志第55天 2020.8.31
    Java日志第54天 2020.8.30
    测试:ATM
    dear mother
    Spring
    People like me
  • 原文地址:https://www.cnblogs.com/qinlixue/p/2913588.html
Copyright © 2020-2023  润新知