Article View: borland.public.cppbuilder.nativeapi
Article #13724Re: Getting IP Adress
From: Michael Gillen
Date: Fri, 19 Sep 2003 19:39
Date: Fri, 19 Sep 2003 19:39
38 lines
1837 bytes
1837 bytes
Play with this:
#include <winsock2.h>
//--------------------------------------------------------------------------
-
void __fastcall ShowMeTheLocalIps()
{
WSADATA wsa = {0};
if( ::WSAStartup(MAKEWORD(2, 0), &wsa) != 0 )
{
ShowMessage("The requested WinSock (version 2) is not available");
return;
}
char buffer[65] = {0};
if( ::gethostname(buffer, sizeof(buffer)) == 0 )
{
struct hostent *host = ::gethostbyname(buffer);
if( host )
{
for(int x = 0; host->h_addr_list[x] != NULL; ++x)
ShowMessage( ::inet_ntoa(*(in_addr*)host->h_addr_list[x]));
}
}
::WSACleanup();
}
-Michael
"Andreas Osswald" <no.valid@email.adress.de> wrote in message
news:3f6aa66f$1@newsgroups.borland.com...
> Hi,
> Is it possible to get the IP adress from the own PC e.g. as showed with
> ipconfig ?
>
> Best thanks for any help,
> Andreas
>
>
Technical Details
Message-ID:
<3f6b5b63$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f6aa66f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,e6c240f3a3c6ca6d X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-19 12:42:47 PST From: "Michael Gillen" <mgillen@gillenconsultinggroup~removeme~.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f6aa66f$1@newsgroups.borland.com> Subject: Re: Getting IP Adress Date: Fri, 19 Sep 2003 12:39:16 -0700 Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.122.199.249 Message-ID: <3f6b5b63$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1064000355 67.122.199.249 (19 Sep 2003 12:39:15 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail