Czy za pomoca delphi jest mozliwe odczytanie IP zewnetrznego??:) jak tak to prosze o jakas wskazowke:P
0
0
Pobierz sobie http://whatismyip.com i bedziesz miał IP, pod którym jestes widoczny w necie (twoje, albo twojej bramy internetowej).
0
function GetIP: String;
var
WebAddress, SearchString: string;
TempInt: Integer;
NMHTTP1 : TNMHTTP;
txt : String;
begin
WebAddress := 'http://www.whatismyip.com/';
SearchString := '<TITLE>Your ip is ';
NMHTTP1 := TNMHTTP.Create(nil);
try
NMHTTP1.Get(WebAddress);
except
on E: Exception do
begin
// reakcja na blad, np jak nie moze polaczyc sie z internetem, lub cos takiego.
end;
end;
txt := NMHTTP1.Body;
TempInt:=Pos(SearchString,txt);
txt := Copy(txt,TempInt+Length(SearchString),15);
TempInt:=Pos(' ',txt);
txt:=Copy(txt,1,TempInt);
Result := txt;
Form1.caption:='IP: '+txt;
end;
LUB INNY JUŻ MÓJ SPOSÓB :)
procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.Navigate('www.whatismyip.com');
end;
procedure TForm1.WebBrowser1TitleChange(Sender: TObject;
const Text: WideString);
var
s:String;
begin
s:=text;
s:=stringreplace(s,'Your ip is ','',[rfreplaceall,rfignorecase]);
s:=stringreplace(s,' WhatIsMyIp.com','',[rfreplaceall,rfignorecase]);
edit1.Text:=s;
edit1.Text:=StringReplace(edit1.text,' ','',[rfreplaceall]);
end;
end.
Tylko w tym drugim zamiast NMHTTP wkładasz webbrowsera i buttona czy co tam chcesz