[英]How to get specific registry key subkey
Anybody knows, how can get programmatically get subkey like 0001 , 0002 , or 0005 and so on ? 有谁知道,如何以编程方式获得像0001,0002或0005等子键? From
从
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
In these keys 0001 , 0002 ... gas stored information about NIC cards ! 在这些键0001,0002 ...气体存储有关NIC卡的信息!
Use the Microsoft.Win32.Registry
/ .RegistryKey
classes. 使用
Microsoft.Win32.Registry
/ .RegistryKey
类。
Example: 例:
using Microsoft.Win32;
...
//Where CardInformation is some data structure to hold the information.
public static IEnumerable<CardInformation> GetCardInformation()
{
string cardsKeyAddress = "\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}";
RegistryKey cardsKey = Registry.LocalMachine.OpenSubKey(cardsKeyAddress);
string[] cardNumbers = cardsKey.GetSubKeyNames();
foreach(string n in cardNumbers)
yield return LoadCardInformation(cardsKeyAddress+"\\"+n);
}
static CardInformation LoadCardInformation(string key)
{
//Get whatever values from the key to return
CardInfomation info = new CardInformation();
info.Name = Registry.GetValue(key, "Name", "Unnamed");
return info;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.