Article View: borland.public.cppbuilder.nativeapi
Article #11398Re: retrieve my IP Address.
From: Roberto
Date: Sun, 08 Feb 2004 11:05
Date: Sun, 08 Feb 2004 11:05
50 lines
2398 bytes
2398 bytes
Try use de command line DOS ipconfig.exe , you have to create a batch
file to execute the ipconfig.exe and send the stdout to a file like
ipconfig.txt , them you get the information you want
HANDLE hfileIP;
DWORD nr, FileSizeLow, FileSizeHigh, totalF;
SHELLEXECUTEINFO ExecInfo;
memset (&ExecInfo, 0, sizeof(ExecInfo));
ExecInfo.cbSize = sizeof(ExecInfo);
ExecInfo.lpVerb = "open";
ExecInfo.lpFile = "IP.bat"; // create a batch file with:
ipconfig > ipconfig.txt
ExecInfo.lpParameters = "";
ExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ExecInfo.nShow = SW_HIDE;
if (!ShellExecuteEx(&ExecInfo))
ShowMessage("Couldn't find command");
hfileIP = CreateFile("ipconfig.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if( hfileIP!=INVALID_HANDLE_VALUE){
FileSizeLow=GetFileSize(hfileIP,&FileSizeHigh);
totalF=(FileSizeHigh * MAXDWORD) + FileSizeLow;
char* buffer = (char*) new CHAR[totalF+1];
ReadFile(hfileIP, buffer,totalF, &nr, NULL );
buffer[totalF]='\0';
Memo1->Lines->Append(buffer); // Get all information you want
CloseHandle(hfileIP);
}
Roberto
"Marcello Scala" <mscala@emails.it> escreveu na mensagem
news:4023de99@newsgroups.borland.com...
> Hi All.
> I have a Modem/router and my ip is always 192.168.0.2.
> How can i retrieve my real IP connection?
>
> i'm C++ Builder 6
>
> Thanks
> Marcello
>
>
Technical Details
Message-ID:
<402617e8$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!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4023de99@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f70891bebb04b30f X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-08 03:09:23 PST From: "Roberto" <casa@artecharao.com.br> Newsgroups: borland.public.cppbuilder.nativeapi References: <4023de99@newsgroups.borland.com> Subject: Re: retrieve my IP Address. Date: Sun, 8 Feb 2004 08:05:09 -0300 Lines: 52 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: 200.148.44.56 Message-ID: <402617e8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1076238312 200.148.44.56 (8 Feb 2004 03:05:12 -0800) 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!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail