find Internet IP through router with DelphiPosted by webmaster Guido on January 14, 2005 In Reply to: Internet IP through router posted by Giovanni
Caramia p12316 on January 03, 2005 Your IP address as it is seen *externally* can be different from your *local* IP. This is the case if you access the Internet through another device on your network (router, firewall, another network computer,...) You have to ask another computer on the Internet how it sees your IP. There are pages on the Internet, that display your IP. Surf to such a page and read its text. Writing a Delphi program for this purpose: 1. You need a component that can access a webpage, i.e. that can do a HTTP-get (examples: NMHTTP or similar HTTP component). Let's assume you have received the body of the page in a string variable HTMLBody. const StartText = 'Current IP Address: '; EndText = '</body>'; var StartPos, Leng: integer; IP: string; begin StartPos := Pos(StartText, HTMLBody) + Length(StartText); Leng := Pos(EndText, HTMLBody) - StartPos; IP := Copy(HTMLBody, StartPos, Leng); Cheers, |