读取注册列表信息,碰到读取数字与地址符相结合的注册列表键名
我怀疑是该键名非字符串类型造成无法读取
但是如果我直接使用字符串的连接的方式却可以直接取出相对的数据            RegistryKey Key = null;            ArrayList arrayList = new ArrayList();            try
            {
                //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\HWP2807\5&19f89766&0&11335588&01&00\Device Parameters
                string Monitor = "SYSTEM\\CurrentControlSet\\Enum\\DISPLAY";
                //打开注册列表卸载选项
                //SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
                Key = Registry.LocalMachine.OpenSubKey(Monitor);
                if (Key != null)
                {
                    foreach (String MonitorKeyName in Key.GetSubKeyNames())
                    {
                        if (MonitorKeyName != "Default_Monitor")
                        {
                            Console.WriteLine("MonitorKey:" + MonitorKeyName);                            //打开对应的
                            RegistryKey MonitorKey = Registry.LocalMachine.OpenSubKey(Monitor + "\\" + MonitorKeyName);                            foreach (String keyname in MonitorKey.GetValueNames())
                            {
                                //这里无法获取到下面的数字与地址符组合的键名称
                                string KeyName = @"5&19f89766&0&11335588&01&00";
                                
                                arrayList.Add("keyName:" + KeyName);
                                //keyName like 5&19f89766&0&11335588&01&00
                                Console.WriteLine("keyName:" + KeyName);                                RegistryKey EDIDKey = MonitorKey.OpenSubKey(KeyName + "\\Device Parameters");
                                if (EDIDKey != null)
                                {
                                    arrayList.Add("EDIDKey:" + EDIDKey.ToString());
                                    String EDID = EDIDKey.GetValue("EDID", "Nothing").ToString();
                                    if (EDID != "Nothing")
                                    {
                                        arrayList.Add(EDID);
                                    }
                                }// if EDID key not null
                            }
                        }//if subkey name not "Default_Monitor"
                    }
                }//if key not null
            }
希望熟悉注册列表的朋友帮忙解答下

解决方案 »

  1.   

    获取系统中所有显示器?Screen 对象
      

  2.   

    // 你的代码有个地方写错了
    // foreach (String keyname in MonitorKey.GetValueNames())
    // 应该是 GetSubKeyNamesstring MONITORs = "SYSTEM\\CurrentControlSet\\Enum\\DISPLAY";using (RegistryKey DISPLAY = Registry.LocalMachine.OpenSubKey(MONITORs))
    {
        if (DISPLAY == null) return;    foreach (string name in DISPLAY.GetSubKeyNames())
        {
            if (name == "Default_Monitor") continue;        Console.WriteLine("{0}", name);        using (RegistryKey SN = DISPLAY.OpenSubKey(name))
            {
                if (SN == null) continue;            foreach (string number in SN.GetSubKeyNames())
                {
                    Console.WriteLine("\t{0}", number);                using (RegistryKey PARAM = SN.OpenSubKey(number + "\\Device Parameters"))
                    {
                        if (PARAM == null) continue;                    object EDID = PARAM.GetValue("EDID");                    if (EDID != null)
                        {
                            Console.WriteLine("\t\t{0}", BitConverter.ToString(EDID as byte[]));
                        }
                    }
                }
            }
        }
    }