How to use win api to check if the network is a pay-per-traffic link

Viewed 70

I see that since windows8 users can set up network as a pay-per-traffic internet link, so maybe some apps will use less data traffic

But I can't find an easy to use api to determine if the current network is billed or not when developing c++ applications

Does anyone have a link to the documentation for this?

1 Answers

Windows::Networking::Connectivity::NetworkInformation class is what you seek.

The GetInternetConnetionProfile method on this class returns a ConnectionProfile instance. On that object, you can invoke GetConnectionCost to get the NetworkCostType enum property. There's an event you can register a callback for when the user roams between networks so you know when to query it again.

If this property is "fixed" or "variable", you're on some sort of "metered network" connection where you might not want to have your app be conservative on network usage.

With that in mind, I believe the property that sets this bit simply a property of the network adapter. And maps to the user setting buried in Windows Settings:

enter image description here

I could be mistaken, but I'm not sure if there's any well known standard by which a network or ISP advertises the metered connection property dynamically in which Windows will pick it up. I think the OEM of the device sets this toggle switch when the machine is imaged.

Related