The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: RobinHE on February 26, 2007, 05:02:32 PM

Title: How to get local IP address under Win32 (WinXP)?
Post by: RobinHE on February 26, 2007, 05:02:32 PM
Hello, I am a total newbie to 32-bit ASM but am experienced in 16-bit ASM (under MS-DOS). I am learning using MASM32 and great sources of information such as this forum!

I would like to know how to fetch the IP address of a local network adapter (and for test purposes simply wish to convert to a string and display it). My OS is Windows XP SP2 and the IP address for the local adapter has been assigned by DHCP. Do I use an API for this? Any help would be very much appreciated, thank you.
Title: Re: How to get local IP address under Win32 (WinXP)?
Post by: ragdog on February 26, 2007, 05:37:41 PM
hi snowydog

here is a small example
i delete getip.zip

i have found a another good  example

greetz
ragdog

[attachment deleted by admin]
Title: Re: How to get local IP address under Win32 (WinXP)?
Post by: Tedd on February 26, 2007, 06:04:26 PM
gethostname to get the name of your machine, and then gethostbyname to get the ip of the given host.

Example attached (you can have more than one ip assigned, so it lists all.)


[attachment deleted by admin]
Title: Re: How to get local IP address under Win32 (WinXP)?
Post by: RobinHE on February 26, 2007, 09:25:27 PM
Thanks Tedd and ragdog, your examples are very helpful. Being new to Win32 ASM programming, is there a good resource (book, online etc..) you would recommend to me for getting detailed information on the various APIs ?
Title: Re: How to get local IP address under Win32 (WinXP)?
Post by: Tedd on February 27, 2007, 12:34:35 PM
Iczelion's tutorials are a pretty good start - which you can find here: http://www.movsd.com/icz.htm (they may also be included in the masm32 package - they were, not sure now.)

If you can find a good reference then that's always helpful - you can browse the different function and find out what they do - http://msdn2.microsoft.com/en-us/library/default.aspx is the obvious choice, but I prefer an offline reference (do a little searching for the win32.hlp file :wink)

And.. then there's always us :bg Post any random question and you're likely to get a useful answer (and maybe ten more.)