How to know the current computer's IP address?

 
Thanks.
 
"ipconfig" in the command line
 
Thanks. I want to know ip address through MQL4 and only trade with a certain ip address.
 

1. maybe .ex4 callable windows i/f codes to give cmd to so can do DOS stuff and get maybe into file then u read...

2. maybe .dll better way? not big code, for those in know ;)

.

i add below - is link to thread talk maybe interest?

DLL Help

 

Writing a dll for this wouldn't be that hard.

Don't know if I have the time right now to do so though.


You are wanting the internet IP of the machine correct?

 
Hi, I need to know system IP address by using MQL4 code to limit the usage of my EA. Could you help to tell me which .dll I should use? I've been searching all over, winsock, kernel, but can't find it. Thanks.
 
yewnix: Writing a dll for this wouldn't be that hard.

Don't need to write a dll, just call the Window's DLL (winsock.dll)

You'll have to create a #import and functions to properly access the data. Compare the kernal32 GetTimeZoneInformation definitions with the attached (pre-Build 600) TimeGMT

Files:
timegmt.mq4  1 kb
 
WHRoeder:

Don't need to write a dll, just call the Window's DLL (winsock.dll)

You'll have to create a #import and functions to properly access the data. Compare the kernal32 GetTimeZoneInformation definitions with the attached (pre-Build 600) TimeGMT

The local machine doesn't necessarily know its IP address. If it is behind something like a normal domestic broadband router doing NAT, then the router has a public IP address but all the computers sitting behind it only have private and non-unique addresses such as 192.168.0.123.

There's nothing you can query on the local machine which is guaranteed to give you a public IP address. (Stringo's suggestion above about ipconfig is similarly wrong; on a computer such as the one I'm using to type this, ipconfig will only tell you the private non-unique address allocated to the machine, not the public address assigned to the router).

The only easy way of getting the IP address is to bounce a message off  a server on the internet: e.g. do a WebRequest to a server which responds with the IP address it is getting called from. In other words, do a WebRequest to something similar to http://www.whatsmyip.org/, but better designed for automated processing of the response.

 
... and going back to the reason for the most recent question, trying to use the IP address for software licensing is a really, really bad idea. Most ISPs use dynamic addresses, and a user's IP address will typically change at least every few days.
 
Yes, jjc, it happened a few days ago when the electricity is off thus my modem is switched off. When it comes back online, the ip address changed. So, do you have any suggestion on how to limit expert advisor to run in certain PC only
 
positivezero:
Yes, jjc, it happened a few days ago when the electricity is off thus my modem is switched off. When it comes back online, the ip address changed. So, do you have any suggestion on how to limit expert advisor to run in certain PC only

The simple answer is to lock against an account number, not a computer (or variants such as providing unfettered use on demo accounts, but requiring a licence for live accounts).

If you really want to lock against the hardware, then it's the same answer as https://www.mql5.com/en/forum/128665. It's a compromise between security and simplicity. Something like GetVolumeInformation() is easy to implement, but also creates a fairly easy way for someone to share a valid licence with other people/computers. (What's changed since https://www.mql5.com/en/forum/128665 is that MQL4 code is now much harder to decompile.)