LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Get IP Subnet Mask Programmatically

Solved!
Go to solution

Hi, all,

 

for my user interface application (communicate with the control system via some external LWIP library) would be very useful know if the host network card is able (that means is properly configured) to communicate with desired IP address.

I have a idea to use GetAllTCPHostAddresses () function - and obtain the available IP host interfaces. But how to get the appropriate IP subnet mask for each interface?

Any hint will be appreciated!

 

Thanks,

George

0 Kudos
Message 1 of 4
(6,034 Views)

There is a good example written by NickB here: it retrieves and prints the default gateway and IP address. You can print the subnet mask by adding this line to PrintAdapterInfo () function:

 

printf ("  IP subnet mask: %s\n\n", adapterInfo->IpAddressList.IpMask.String);

You need to add IPHlpApi.Lib to the project in order to use run it.

 

There are a lot of useful informations offered by IP Helper APIs: the only problem is that you need full CVI package to use them. If you have the base package you may consider to call ipconfig redirecting the output to a file, next parsing the output file. See later in the discussion I linked above.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 4
(6,015 Views)
Solution
Accepted by topic author DocRabbit

Hi, Roberto,

that's just what I wanted, thank's a lot!

Now I have tested and it's work good.

Cheers,

George

0 Kudos
Message 3 of 4
(6,005 Views)

I'm happy to have helped you finding the correct information in the forum.

I have kudoed Nick post which really is the solution to your problem and it's a good example of how to use these functions.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(5,997 Views)