1

0001 、 0002 、または 0005 などのサブキーをプログラムで取得する方法を知っている人はいますか? から

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

これらのキー 0001、0002 には、NIC カードに関する情報が格納されています。

4

2 に答える 2

2

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;
}
于 2012-07-30T13:21:37.820 に答える
1

Microsoft.Win32.Registry同じクラスを使用してそれを行うことができます。詳細はこちら

于 2012-07-30T11:57:37.407 に答える