Article View: borland.public.cppbuilder.nativeapi
Article #4676Re: all IP adresses of the local system
From: Dennis Jones
Date: Tue, 20 Dec 2005 17:49
Date: Tue, 20 Dec 2005 17:49
32 lines
2007 bytes
2007 bytes
"Andreas Osswald" <noname@noname.de> wrote in message
news:43a832cb$1@newsgroups.borland.com...
> Is there a possibility to get all the IP adresses of my computer. Ther are
> serverals nic installed, and i wont all adresses. At the moment i use the
> class TIpSocket but i get only one adress.
Yes, use GetAdaptersInfo(). For example:
ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
boost::scoped_array<char> pAdapterInfo( new char[ulOutBufLen] );
// Make an initial call to GetAdaptersInfo to get
// the necessary size into the ulOutBufLen variable
if (GetAdaptersInfo( (PIP_ADAPTER_INFO)pAdapterInfo.get(), &ulOutBufLen)
== ERROR_BUFFER_OVERFLOW)
{
pAdapterInfo.reset( new char[ ulOutBufLen ] );
}
if (GetAdaptersInfo( (PIP_ADAPTER_INFO)pAdapterInfo.get(), &ulOutBufLen)
== NO_ERROR)
{
PIP_ADAPTER_INFO pAdapter = (PIP_ADAPTER_INFO)pAdapterInfo.get();
while (pAdapter)
{
AnsiString AdapterAddress =
pAdapter->IpAddressList.IpAddress.String;
}
}
- Dennis
Technical Details
Message-ID:
<43a843e2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43a832cb$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,744a3315ee7b00aa X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dennis Jones" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <43a832cb$1@newsgroups.borland.com> Subject: Re: all IP adresses of the local system Date: Tue, 20 Dec 2005 09:49:49 -0800 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 204.200.27.7 Message-ID: <43a843e2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1135100898 204.200.27.7 (20 Dec 2005 09:48:18 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail