Know the hostname and IP lazarus / 8-Other ---------------------------------------------------------------------- cpalx · 2009-01-02 16:36 if the program is running in a machine, how can i get the hostname and the IP? thanks ---------------------------------------------------------------------- cpalx · 2009-01-03 21:42 i installed succesfully indy componets, is somebody knows how to use to obtein the local IP and its hostname? ---------------------------------------------------------------------- cpalx · 2009-01-03 21:50 i made it we need TIdIPWatch  component from "Indy Misc Protocoles" palete the lets active and in a button click event just write showmessage( IdIPWatch.CurrentIP); i hope somebody helps -- Christian ---------------------------------------------------------------------- cpalx · 2009-01-03 21:52 now, i need the hostname, i will continue watching -- Christian ---------------------------------------------------------------------- evoshroom · 2012-07-11 05:16 I would love to know how you can find your external IP as well.  Haven't found a cross-platform method yet using Synapse, Lnet or basic free pascal. ---------------------------------------------------------------------- libya · 2013-01-24 04:04 Quote from: cpalx on January 02, 2009, 05:36:15 pmif the program is running in a machine, how can i get the hostname and the IP? thanks Even though the program is running in a machine you can get your IP address from Ip-Details.com  By using that IP address you can get your hostname from the site WhoisXY.com  and it also shows your whois information. ---------------------------------------------------------------------- wjackson153 · 2013-01-24 04:31 You can use Tprocess to find the ip, host name, currently logged in user etc and its cross platform dependant just pass   ipconfig /all to a process and redirect output to your application, parse the information back into your app Look up my past post it goes into more details. ---------------------------------------------------------------------- evoshroom · 2013-01-24 04:34 QuoteYou can use Tprocess to find the ip, host name, currently logged in user etc and its cross platform dependant just pass   ipconfig /all to a process and redirect output to your application, parse the information back into your app Look up my past post it goes into more details. I doubt that works.  For example on OS X: ipconfig getifaddr en0 That outputs my local IP, 192.168.1.101, not my Internet IP. ---------------------------------------------------------------------- BigChimp · 2013-01-24 10:49 Agreed with evoshroom. IIRC, there is already sample code on the forum that queries e.g. whatismyip.com and gets the external IP address. You could use synapse, wget, whatever to get that. Perhaps it's even on the wiki already - if not it might be a good addition. ---------------------------------------------------------------------- BigChimp · 2013-01-27 11:25 FYI, modified a post by jostudio and added it here: http://wiki.lazarus.freepascal.org/fphttpclient Thanks, jostudio! Hope people with synapse, indy etc examples will post it on the respective wiki pages and direct people with this recurring question there ---------------------------------------------------------------------- wjackson153 · 2013-01-29 03:29 Will return your External IP  For linux Code: [Select]Procedure TForm1.Button1Click(Sender: TObject); var     hprocess: TProcess; Begin    hProcess := TProcess.Create(nil);    hProcess.Executable := '/bin/sh';    hprocess.Parameters.Add('-c');    hprocess.Parameters.add('wget -q -O - http://myexternalip.com/raw');    hProcess.Options := hProcess.Options + [poWaitOnExit, poUsePipes];    hProcess.Execute;    memo1.Lines.LoadFromStream(hprocess.Output);    hProcess.Free;  end;        If anyone knows a way to store to a a string rather then a memo another then pulling it from the memo then to a string IE:  var ExternalIp: String; begin ExternalIP := hprocess.output;         // does not work it expects TinputPipeStream end;