Is it possible to check whether my laptop is connected through a Wi-Fi or through a "wired LAN" programmatically in Windows C++?
I need to know if my PC is communicating through WiFi, LAN, VPN… My application creates heavy network load and there is no point in launching in certain cases, that is why I need t开发者_运维百科o know through which connection the PC communicates to the world…
One brute force way might works:
The idea is to parse the ipconfig/ifconfig output.
First get a list of UP interfaces (e.g. lan0, wlan0) which are your candidates. Then send some data (e.g. ping google.com), compare the Rx packets and tx packets number before and after sending data and you should be able to get which interface is being used.
Hope this helps.
精彩评论