As per msdn we should use GetAdaptersAddresses() instead of GetAdaptersInfor() for Windows XP and later. I need to get all information for NIC ie: IP, Subnet, Gateway, DNS, WINS.
GetAdaptersInfo() does it all, but couldn't find any sample how to retrieve Gateway, Subnet using GetAdaptersAddresses(), Geteway address can be retrieved by GAA_FLAG_INCLUDE_GATEWAYS from Windows Vista, I need to code to support OS from XP, Can anyone suggest anything ?
Last edited by hypheni; November 3rd, 2012 at 02:22 PM.
So far I have completed other work except a few, what should be better approach to get the Connection name.
GetAdaptersInfo returns GUID for the NIC, if using this way to get Connection Name I have to read registry key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}'
GetAdaptersAddress returns FriendlyName of the NIC, ie: the Connection name
Which one will be better ?
Read registry
or
Use GetAdaptersAddress only for FriendlyName, along with GetAdaptersInfo for others.
Last edited by hypheni; November 7th, 2012 at 10:58 AM.
Just a small update. I tried both API in my sample application and application reaches using 6MB of memory where as using GetAdaptersInfo takes only 1.5MB memory.
Wasting 4.5MB memory only for retrieving one single information which can be queried from registry. Is it worthy using both APIs in single application.
Don't mention as its a desktop application I shouldn't care about memory. I like keep my application use only required memory.
Bookmarks