unit Unit1;
interface
uses
Windows, Messages, winsock, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 =
class(TForm)
btn1: TButton;
Label1: TLabel;
IdHTTP1: TIdHTTP;
Label2: TLabel;
IdHTTP2: TIdHTTP;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure btn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
IPADRESSE:
String;
const
HOSTNAMEN='
xxxx.xxxxxx.de';
USERNAME ='
xxxxxxxxxx';
PASSWORT ='
**********';
implementation
{$R *.dfm}
Function GeExtIP:
string;
var ndx: integer;
begin
//result:=uppercase(Form1.IdHTTP1.Get('http://checkip.dyndns.com'));
result:=uppercase(Form1.IdHTTP1.Get('
http://meineip.softwareschuhmann.de'));
if result='
'
then result:='
GET failed'
else
begin
ndx:=pos('
:',result);
if ndx=0
then result:='
host not found'
else
begin
delete(result,1,ndx);
delete(result,pos('
<',result),Length(result));
result:=trim(result);
end;
end;
end;
Function UpdateIP:
string;
// für Strato
begin
Form1.IdHTTP2.Request.BasicAuthentication:=True;
Form1.IdHTTP2.Request.Username:=USERNAME;
Form1.IdHTTP2.Request.Password:=PASSWORT;
result:=Form1.IdHTTP2.Get(Format('
http://dyndns.strato.com'
+'
/nic/update?system=dyndns&hostname=%s&myip=%s'
,[HOSTNAMEN,IPADRESSE]));
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
IPADRESSE:=GeExtIP;
label1.Caption:= IPADRESSE;
Label2.Caption:=UpdateIP;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Label5.Caption:= HOSTNAMEN;
btn1click(self);
end;
end.