0001 、 0002 、または 0005 などのサブキーをプログラムで取得する方法を知っている人はいますか? から
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
これらのキー 0001、0002 には、NIC カードに関する情報が格納されています。
Microsoft.Win32.Registry
/.RegistryKey
クラスを使用します。
例:
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;
}
Microsoft.Win32.Registry
同じクラスを使用してそれを行うことができます。詳細はこちら