2012-07-30 4 views
1

누구든지 프로그래밍 방식으로 0001, 0002 또는 0005 등의 하위 키를 가져올 수 있습니다. 이러한 키에특정 레지스트리 키 하위 키를 얻는 방법

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

에서 0001, NIC 카드에 대한 0002 ... 가스 저장되는 정보!

답변

1

Microsoft.Win32.Registry과 같은 클래스를 사용하면됩니다. 자세히보기 here

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; 
} 
관련 문제