Board index » cppbuilder » How to get the configured subnet mask for this machine?

How to get the configured subnet mask for this machine?


2006-04-13 05:41:53 AM
cppbuilder39
Anyone know how to use WINAPI to retrieve the subnet mask for a given
interface? I can programmatically retrieve a list of IP addresses with
gethostbyname, but this doesn't deal with configured subnets.
What's behind all this is I need an application to send a subnet
broadcast message on startup to find other instances of itself. Running
IPCONFIG from a shell is messy, and I can't find anything on MSDN.
TIA
Mike
 
 

Re:How to get the configured subnet mask for this machine?

12 Apr 2006 14:41:53 -0700, Mike Knoblock < XXXX@XXXXX.COM >wrote:
Quote
Anyone know how to use WINAPI to retrieve the subnet mask for a given interface?
msdn.microsoft.com/library/default.asp
Quote
I can programmatically retrieve a list of IP addresses with gethostbyname,
but this doesn't deal with configured subnets.

What's behind all this is I need an application to send a subnet broadcast message
on startup to find other instances of itself. Running IPCONFIG from a shell is messy,
and I can't find anything on MSDN.
--
JF Jolin
 

Re:How to get the configured subnet mask for this machine?

I looked; I swear!
Thanks!!
JF Jolin wrote:
Quote
12 Apr 2006 14:41:53 -0700, Mike Knoblock < XXXX@XXXXX.COM >wrote:

>Anyone know how to use WINAPI to retrieve the subnet mask for a given
>interface?

msdn.microsoft.com/library/default.asp


>I can programmatically retrieve a list of IP addresses with
>gethostbyname,
>but this doesn't deal with configured subnets.
>
>What's behind all this is I need an application to send a subnet
>broadcast message
>on startup to find other instances of itself. Running IPCONFIG from a
>shell is messy,
>and I can't find anything on MSDN.


 

{smallsort}

Re:How to get the configured subnet mask for this machine?

"Mike Knoblock" < XXXX@XXXXX.COM >wrote in message
Quote
Anyone know how to use WINAPI to retrieve the subnet mask
for a given interface?
Look at the GetAdaptersInfo() function in the IPHLR API:
GetAdaptersInfo
msdn.microsoft.com/library/en-us/iphlp/iphlp/getadaptersinfo.asp
The IP_ADAPTER_INFO structure has several members that deal with IP
addresses and masks. They are all of type IP_ADDR_STRING, which has an
IpMask member.
Quote
I can programmatically retrieve a list of IP addresses with
gethostbyname, but this doesn't deal with configured subnets.
There is nothing in the WinSock API for what you ask.
Gambit