0

I need to detect when the Windows system is connected to/disconnected from network (LAN or WLAN) in C++ and without using WMI.

I have found a way to do this for wireless networks. (I have answered my own question here after finding a way), but this does not work (obviously) when I connect/disconnect a LAN cable.

How can I detect a change in network connection when user has connected a LAN cable to his Windows system? Is there a general way (instead of having separate code for WLAN and LAN) to find this?

Note: The network may or may not be connected to the internet.

NightFuryLxD
  • 847
  • 5
  • 15
  • 1
    The [Windows.Networking.Connectivity namespace](https://learn.microsoft.com/en-us/uwp/api/windows.networking.connectivity) probably has everything you need. The only challenge left is figuring out how to put all those pieces together. As with anything COM/Windows Runtime there's a severe lack of conceptual documentation. – IInspectable Dec 21 '21 at 12:29
  • 2
    you can use [`INetworkListManager::GetConnectivity`](https://learn.microsoft.com/en-us/windows/win32/api/netlistmgr/nf-netlistmgr-inetworklistmanager-getconnectivity) - [Network Awareness in Windows Vista and Windows 7](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mpc/network-awareness-on-windows-vista-and-windows-7) or [Network Awareness in Windows XP](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mpc/network-awareness-in-windows-xp) – RbMm Dec 21 '21 at 12:31
  • Thank you. Will check out these links and get back to you. – NightFuryLxD Dec 21 '21 at 13:42

0 Answers0