2012-07-30 2 views
1

Кто-нибудь знает, как получить программный доступ к разделу, например 0001, 0002 или 0005, и так далее? ОтКак получить конкретный раздел раздела реестра

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

В этих ключей 0001, 0002 ... газ хранится информация о NIC карт!

ответ

1

Вы можете использовать Microsoft.Win32.Registry и те же классы, чтобы это сделать. Подробнее here

2

Используйте классы /.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; 
} 
Смежные вопросы