uses ComCtrls, ExtCtrls, OleCtrls, SHDocVw
var
Tentative : Byte;
procedure Connect;
begin
if (Tentative = 1) then
Form1.WebBrowser1.Navigate('http://checkip.dyndns.org');
if (Tentative = 2) then
Form1.WebBrowser1.Navigate('http://www.adresseip.com');
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
S, IP : String;
i :Integer;
begin
beep;
S := WebBrowser1.OleObject.Document.Body.InnerHTML;
If (Tentative = 2) then
begin
if (Pos('Ihre IP-Adresse ist',S) <> 0) then
begin
i := Pos('Ihre IP-Adresse ist',S)+67;
While (S[i] <> ' ') do
begin
IP := IP + S[i];
inc(i);
end;
Edit1.Text := IP;
Button1.Enabled := true;
WebBrowser1.Stop;
end
else
begin
Edit1.Text := 'Überprüfen Sie Ihre Verbindung.';
Button1.Enabled := true;
end;
end;
If (Tentative = 1) then
begin
if (Pos('Current IP Address: ',S) <> 0) then
begin
i := 21;
While (S[i] <> ' ') do
begin
IP := IP + S[i];
inc(i);
end;
Edit1.Text := IP;
Button1.Enabled := true;
WebBrowser1.Stop;
end
else
begin
Tentative := 2;
Connect;
end;
end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
Tentative := 1;
Edit1.Text := 'Warte !';
Button1.Enabled := false;
Connect;
end;
Keine Kommentare:
Kommentar veröffentlichen