forLord
asked on
how can I get default gateway?
I tried some function but them dont work out.
Tell me some function to do this after your examination!Do give me anything you haven't haven a examination! had better give me full unit and function name to use this unit after your examination!I will give everyone A grade who answer regardless of your answer is correct or not correct!
had better dont use function of get register value
beacuse my register of gateway is strange such: HKEY_LOCAL_MACHINE/SYSTEM/ CurrentCon trolSet/Se rvices/{42 03270B-BDA F-418B-BF4 1-25697705 80C4}/Para meters/Tcp ip/Default Gateway
So I want such API function to get defaultgateway ,beacuse I want to get default gateway regardless of which way to register.
I have use some function:
function my_ip_address:longint;
const
bufsize=255;
var
buf: pointer;
//str: string;
RemoteHost : PHostEnt; (* No, don't free it! *)
begin
buf:=NIL;
try
getmem(buf,bufsize);
winsock.gethostname(buf,bu fsize); (* this one maybe without domain *)
RemoteHost:=Winsock.GetHos tByName(bu f);
if RemoteHost=NIL then
my_ip_address:=winsock.hto nl($070000 01) (* 127.0.0.1 *)
else
my_ip_address:=longint(poi nter(Remot eHost^.h_a ddr_list^) ^);
//str:= inet_addr(pointer(RemoteHo st^.h_addr _list^)^);
finally
if buf<>NIL then freemem(buf,bufsize);
end;
result:=winsock.ntohl(resu lt);
end;
function LongToIp(Long: Longint): string;
var
ipx: array[0..3] of Byte;
i: Byte;
begin
Longint(ipx) := long;
Result := '';
for i := 0 to 3 do Result := Result + IntToStr(ipx[i]) + '.';
SetLength(Result, Length(Result) - 1);
end;
but I don't have haven the correct answer from thoese two function
My Default GetWay:192.168.1.1 vpn host
my ip :192.168.1.103 in vpn
The GetWay above 192.168.1.1 : 218.86.198.1
mask:225.225.225.0
first DNS:202.98.192.68
second DNS:192.168.1.11
with the two function run
I got getway as 128.1.1.223 why?
where did 128.1.1.223 come from?
and I ping 128.1.1.223 I cant ping through it.
I can ping through 192.168.1.1 192.168.1.103 218.86.198.1 first DNS:202.98.192.68
second DNS:192.168.1.11
Tell me some function to do this after your examination!Do give me anything you haven't haven a examination! had better give me full unit and function name to use this unit after your examination!I will give everyone A grade who answer regardless of your answer is correct or not correct!
had better dont use function of get register value
beacuse my register of gateway is strange such: HKEY_LOCAL_MACHINE/SYSTEM/
So I want such API function to get defaultgateway ,beacuse I want to get default gateway regardless of which way to register.
I have use some function:
function my_ip_address:longint;
const
bufsize=255;
var
buf: pointer;
//str: string;
RemoteHost : PHostEnt; (* No, don't free it! *)
begin
buf:=NIL;
try
getmem(buf,bufsize);
winsock.gethostname(buf,bu
RemoteHost:=Winsock.GetHos
if RemoteHost=NIL then
my_ip_address:=winsock.hto
else
my_ip_address:=longint(poi
//str:= inet_addr(pointer(RemoteHo
finally
if buf<>NIL then freemem(buf,bufsize);
end;
result:=winsock.ntohl(resu
end;
function LongToIp(Long: Longint): string;
var
ipx: array[0..3] of Byte;
i: Byte;
begin
Longint(ipx) := long;
Result := '';
for i := 0 to 3 do Result := Result + IntToStr(ipx[i]) + '.';
SetLength(Result, Length(Result) - 1);
end;
but I don't have haven the correct answer from thoese two function
My Default GetWay:192.168.1.1 vpn host
my ip :192.168.1.103 in vpn
The GetWay above 192.168.1.1 : 218.86.198.1
mask:225.225.225.0
first DNS:202.98.192.68
second DNS:192.168.1.11
with the two function run
I got getway as 128.1.1.223 why?
where did 128.1.1.223 come from?
and I ping 128.1.1.223 I cant ping through it.
I can ping through 192.168.1.1 192.168.1.103 218.86.198.1 first DNS:202.98.192.68
second DNS:192.168.1.11
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
who will give me a full unit and function name to use?