|
박동진 님이 쓰신 글 :
: 예를들어 IPCONFIG/ALL
:
: 하면 나오는 내용들중에 DNS 서버의 ip를 알고 싶은데요.
:
: 그럼.
:
아래 저도 레지스트리 첨 써보는 거라 한번 만들어 봤슴당.
근데 내 이름은 왜 저렇게 나올까?
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// get the key of interfaces
long nResult=ERROR_SUCCESS;
HKEY hkInterfaceRoot, hStartKey=HKEY_LOCAL_MACHINE;
nResult=RegOpenKeyEx(hStartKey,
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces",
0L,KEY_READ,&hkInterfaceRoot);
if(nResult==ERROR_SUCCESS){
// get one of interfaces
DWORD NumberOfInterfaces;
nResult=RegQueryInfoKey(hkInterfaceRoot,NULL,NULL,NULL,&NumberOfInterfaces,
NULL,NULL,NULL,NULL,NULL,NULL,NULL);
for(DWORD i=0;i<NumberOfInterfaces;i++){
char Name[MAX_PATH]; DWORD NameLength=MAX_PATH;
nResult=RegEnumKeyEx(hkInterfaceRoot,i,Name,&NameLength,0,0,0,0);
if(nResult==ERROR_SUCCESS) Memo1->Lines->Add(String(i)+"th interface");
HKEY hkInterface;
nResult=RegOpenKeyEx(hkInterfaceRoot,Name,0L,KEY_READ,&hkInterface);
if(nResult==ERROR_SUCCESS){
NameLength=MAX_PATH;
// get the value of NameServer of this interface
// if no nameserver is available, null string is returned
nResult=RegQueryValueEx(hkInterface,"NameServer",NULL,NULL,Name,&NameLength);
if(nResult==ERROR_SUCCESS){
Memo1->Lines->Add("NameServer="+String(Name));
}
RegCloseKey(hkInterface);
}
}
}
RegCloseKey(hkInterfaceRoot);
}
실행결과 ====================================================
Memo1
0th interface
NameServer=210.180.98.68 <= 집에서 쓰는 랜카드의 DNS 설정값
1th interface
NameServer= <= 모르는 놈들.
2th interface <= 이놈은 아예 DNS 가 없슴. 무슨 서비스일까?
3th interface
NameServer= <= 모르는 놈들.
4th interface
NameServer=210.220.163.82 210.94.6.67 <= ADSL 이 자동설정한 DNS 설정값
|