News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Getting IP number from the system

Started by nrdev, June 15, 2009, 02:33:24 PM

Previous topic - Next topic

nrdev

I'am confused I have found many functions that are related to the IP, but I don't know witch one I should use to get IP from the system.

What function should I use for this?

Slugsnack


nrdev

You see I don't know witch is witch, I want my program to get the IP from the system. As far as I know IP have the same layout for servers and for normal PCs.

ecube

well private address is the address no one remotely can access, for instance your loopback address which is 127.0.0.1/localhost. Routers have internal addresses that are usually 192.168.*.*. So to access my router for instance it's http://192.168.0.1. To get your remote ip the easiest way is to  connect to whatismyipaddress.com or similar and parse the return(some give only the ip address no other data so its easy). You can also setup a php on a remote server and have your program visit it

;test.php

$v_ip = $_SERVER['REMOTE_ADDR'];
if (strstr($v_ip, ', ')) {
   $ips = explode(', ', $v_ip);
   $v_ip = $ips[0];

echo $v_ip;


windows wininet functions are easy to use to visit and grab the IP. Another method if you use a router is to connect via UPNP functions and grab it from there, but thats alil more tricky. You can loop through network cards on the system to get their interal ip address, quite a few examples of that on here and madwizard.

nrdev

I have found this functions in masm32.inc, but I don't know how to use them, can someone, show me an example of usage of this functions?

IPtoString      PROTO :DWORD,:DWORD
GetIP           PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

dedndave

you are looking at the protos
masm32\m32lib\getip.asm

nrdev

ok, I can get IP, but I can't make it appear correctly in the DlgIPAddress. How can I solve this problem, I have converted my ip to string with IPtoString function.