"Jason Heine"(이름을 태그하는 방법을 모른다) 코드를 C++에 updeted했습니다. 이제는 효과가있다. 그에게 thnx 방법에 의해.
using namespace System;
using namespace System::Net;
void main(){
String ^strHostName = String::Empty;
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns::GetHostName();
Console::WriteLine("Local Machine's Host Name: " + strHostName);
// Then using host name, get the IP address list..
IPHostEntry^ ipEntry = Dns::GetHostEntry(strHostName);
array<IPAddress^> ^addr = ipEntry->AddressList;
for (int i = 0; i < addr->Length; i++)
{
Console::WriteLine("IP Address {0}: {1} ", i, addr[i]->ToString());
}
Console::ReadKey();
}
내가 당신을 도울 것입니다 희망 : 그래서 이것은 내가 무엇을 얻을 수 있습니다.
테스트 됨 내 PC에서 위피와 유선 LAN을 연결하고 "VMware Player"에 대한 가상 카스는 거의 없으며 4 개의 IPv6를 얻은 다음 4 개의 IPv4로 포기합니다. IPv4 만 필요한 경우 다음을 사용할 수 있습니다.
using namespace System;
using namespace System::Net;
void main(){
String ^strHostName = String::Empty;
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns::GetHostName();
Console::WriteLine("Local Machine's Host Name: " + strHostName);
// Then using host name, get the IP address list..
IPHostEntry^ ipEntry = Dns::GetHostEntry(strHostName);
array<IPAddress^> ^addr = ipEntry->AddressList;
for (int i = 0; i < addr->Length; i++)
{
if(addr[i]->ToString()->Length < 20){
Console::WriteLine("IP Address {0}: {1} ", i, addr[i]->ToString());
}
}
Console::ReadKey();
}
그런 다음 IPv4 만 얻을 수 있습니다. 단지 숫자는 4에서 시작됩니다.하지만 나에게는 괜찮습니다. 번호 매기기를 다시 계산하기 위해 새 변수를 추가 할 수 있습니다.