I have multiple adapters just like default one, wifi-net, 3G card with usb etc in Windows.
How to determine which is the activity one? I tried to use GetAdaptersInfo/GetIfEntry but there is no answer. Could someone give me some suggest?
I have multiple adapters just like default one, wifi-net, 3G card with usb etc
Share
I’m not sure what you mean by “activity one”, so I’ll assume you mean “which network adapter is the default for reaching the internet”?
Call GetIpForwardTable. Enumerate the MIB_IPFORWARDROW instances within the table. The rows with the
dwForwardDestmember set to zero are the default routes. In the event of more than one row with thedwForwardDestset to 0 (which can happen if you have more than one adpater), then use thedwForwardMetric1member as the tie-breaker (lowest value wins).Once you find the default route row from
GetIpForwardTable, you can use thedwForwardIfIndexmember to identify which adapter in a call to GetIfTable is the default.