2012-07-30 4 views
1

Tout le monde sait, comment peut se faire comme programme sous-clé 0001, 0002 ou 0005 et ainsi de suite? DeComment obtenir sous-clé clé de Registre spécifique

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

Dans ces clés 0001, 0002 ... gaz des informations stockées sur les cartes NIC!

Répondre

1

vous pouvez utiliser Microsoft.Win32.Registry et les mêmes classes pour le faire. Lire la suite here

2

Utilisez les classes Microsoft.Win32.Registry/.RegistryKey.
Exemple:

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; 
} 
Questions connexes