Hmmm, I was thinking about this, to try to come up with a simple and elegant solution to at least resolving your external ip. Getting the router information IS hard: you either have to create a whole app to poll its information by HTTP or telnet.
After complicating and prevaricating, looking at the most bizarre ways of doing this, it struck me. Even if you can't look out of your LAN with your app,
your webbrowser can! Otherwize you wouldn't be able to connect to TGC, would you.
So, the solution lies in using the existing internet capability already on your computer. You can send an HTTP message to a site and then read its response to find your correct address. What better site to poll than http://whatismyip.org?
You need to put a hidden TWebbrowser-object in your app, and when you start up your app you need to check the IP, and then store it in the app. Hopefully you have the TWebbbrowser-component - otherwise you have to load the SHDOCVW.DLL on your own and create a wrapper for it.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
brw: TWebBrowser;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
strURL, strIP: widestring;
begin
strURL := 'http://www.whatismyip.org';
brw.Visible := false;
brw.Navigate(strURL);
end;
end.
Now all you have to do is store the data that comes back, after parsing it, of course.
-----
They SAID that given enough time a million monkeys with typewriters could recreate the collected works of William Shakespeare... Internet sure proved them wrong.
-----