[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

(A grade for every who answer)I have asked 4 times no one gave me an good answer,this is the 5th:how can I get Default gateway?

Posted on 2005-05-17
6
Medium Priority
?
360 Views
Last Modified: 2010-04-17
Please don't give me link such as

"
For gateway check this:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10232657.html
For the MAC Address
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20297408.html
For the subnet mask check this:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20570057.html
"
no use  I have done experiments

--------------------------------------------------------------------------------------------------------

please give me full  Delphi unit code and fuction name to use it .Please do experiments  to make sure that  your unit work right,before you give your unit code to me!
and I suggest you dont use register function to get it (the reason is below)     API  *.dll  function is the best way I think.

--------------------------------------------------------------------------------------------------------

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!
had better dont  use function of get register value
beacuse my register of gateway is strange   such: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/{4203270B-BDAF-418B-BF41-2569770580C4}/Parameters/Tcpip/DefaultGateway
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,bufsize);   (* this one maybe without domain *)
    RemoteHost:=Winsock.GetHostByName(buf);
    if RemoteHost=NIL then
      my_ip_address:=winsock.htonl($07000001)  (* 127.0.0.1 *)
    else
      my_ip_address:=longint(pointer(RemoteHost^.h_addr_list^)^);
      //str:= inet_addr(pointer(RemoteHost^.h_addr_list^)^);
  finally
    if buf<>NIL then  freemem(buf,bufsize);
    end;
  result:=winsock.ntohl(result);
  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 can't 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

--------------------------------------------------------------------------------------------------------





0
Comment
Question by:justforLord
  • 4
  • 2
6 Comments
 
LVL 13

Accepted Solution

by:
softplus earned 520 total points
ID: 14017049
1) Multiple alias users for the same person are not allowed here ( http://www.experts-exchange.com/help.jsp#hi29 )
2) If you want help, ask in a civilized manner.
3) If you want help, be willing to take the comments and work on the solution yourself as well - we're not here to do the work for you :)
4) Because I'm having a nice-guy day:

Download this: http://www.paranoia.clara.net/downloads/delphi_ipconfigclases_v1-1.zip 
Use this code in your progam:
  var IPConfig TconIPConfig;
  IPConfig.Refresh;
  edtGateway.Text := IPConfig.Adapters[0].Gateways[0];
Taken from here: http://www.paranoia.clara.net/pascal_newsletter/issue0054.html

Note: you can have multiple adapters with multiple gateways... To confirm your settings, try "IPCONFIG /ALL" in a cmd-box.
0
 

Author Comment

by:justforLord
ID: 14017176
3) If you want help, be willing to take the comments and work on the solution yourself as well - we're not here to do the work for you :)  Just in rightness and goodness!I am very willing to work for you all just in rightness!and I am always willing to take the comments  just in rightness!
we're not here to do the work for you: I hope you are just in rightness!
I will do hard work for you all just in rightness!

If you want help, ask in a civilized manner. I think I am very civilized just in rightness!

1) Multiple alias users for the same person are not allowed here   yes,please delete the acount"forLord"  dont delete this account If you think you must delete one of the two account,ok?



0
 

Author Comment

by:justforLord
ID: 14017276
Most honour to the only one and rightness and goodness!
Let's work for eachother just in rightness and goodness!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:justforLord
ID: 14017289
Thank the only one and rightness and goodness!
Let's work for eachother just in rightness and goodness!
0
 
LVL 13

Expert Comment

by:softplus
ID: 14017291
Does that mean the code worked? :)
0
 

Author Comment

by:justforLord
ID: 14025004
Most honour to Lord!
If God agree!

I love God!

you gave me a wonderful delphi code
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Loops Section Overview

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question