|
레지스트리에서 다음과 같이 알아낼 수 있습니다.
String __fastcall TForm1::GetDHCPAddress()
{
String stAddress, stInterfaceKey;
String stMyKey = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
int itInterfaces;
TRegistry *Registry = new TRegistry();
try {
Registry->RootKey = HKEY_LOCAL_MACHINE;
TStringList *InterfacesList = new TStringList;
try {
if(Registry->KeyExists(stMyKey)) {
if(Registry->OpenKeyReadOnly(stMyKey)) {
Registry->GetKeyNames(InterfacesList);
Registry->CloseKey();
for(itInterfaces = 0; itInterfaces < InterfacesList->Count; itInterfaces ++) {
stInterfaceKey = stMyKey + InterfacesList->Strings[itInterfaces] + "\\";
if(Registry->OpenKeyReadOnly(stInterfaceKey)) {
stAddress = Registry->ReadString("DhcpNameServer");
if(stAddress.Trim() == "") return(stAddress);
else return("0.0.0.0");
} else {
return("0.0.0.0");
}
}
}
}
} __finally {
delete InterfacesList;
}
}
__finally
{
delete Registry;
}
return("0.0.0.0");
}
SkyWalker 님이 쓰신 글 :
: 안녕하세요 감사합니다.
:
: 제목그대로 DHCP 서버 주소를 알아내는 방법이 궁금합니다.
: 그럼 답변기다리겠습니다.
|