![]() |
|
#1
|
|||
|
|||
|
Hi guys,
I need to get, Ip, subnet mask, default gateway and wan ip from the local computer, any ideas or examples about how to do this? Cheers
__________________
ERRARE HUMANUM EST |
|
#2
|
|||
|
|||
|
Code:
USES WinSock;
..............................................................
..............................................................
Function GetIPAddress: String;
var
phoste : PHostEnt;
Buffer : array[0..100] of char;
WSAData : TWSADATA;
begin
Result := '';
if WSASTartup($0101, WSAData) <> 0 then
exit;
GetHostName(Buffer,Sizeof(Buffer));
phoste := GetHostByName(buffer);
if phoste = nil then
Result := '127.0.0.1'
else
Result := StrPas(inet_ntoa(PInAddr(phoste^.h_addr_list^)^));
WSACleanup;
end;
__________________
Regards, Abdulaziz Jasser |
|
#3
|
|||
|
|||
|
Quote:
![]() This picks the LAN IP only.
__________________
ERRARE HUMANUM EST |
|
#4
|
|||
|
|||
|
To get the WAN IP use:
Code:
var
thisismyip, IP : String;
l, p1, p2 : integer;
IdHttp1 : TIDhttp;
begin
IdHttp1:= tidhttp.Create(nil);
IdHttp1.HandleRedirects := true;
thisismyip := IdHttp1.get('http://www.showmemyip.com');
L := Length('');
P1 := Pos('',thisismyip);
P2 := Pos('',thisismyip);
IP := Copy(thisismyip,P1 + L, P2 - P1 - L);
IdHttp1.Free;
IPEdt.Text := IP;
__________________
"Where there's a will, there's always a way." -- The Hon Robert Nester Marley O.M. - aka Bob Marley! |
|
#5
|
|||
|
|||
|
Quote:
__________________
ERRARE HUMANUM EST |
![]() |
| Thread Tools | |
| Display Modes | |
|
|