![]() ![]() The adapter Id in fact matches the NetworkInterface.Id Property (it's a string, but you can convert it to a Guid). Then, using the INetworkConnection::GetAdapterId method, you can get a Guid that represent the adapter Id. How can I check current network connections and identify only networks that are not VPN connections, so I can store custom settings for that network?įrom an INetwork instance, you can get the list of connections ( INetworkConnections instances) using the GetNetworkConnections method. ![]() This software will be for users who will connect to networks I know nothing about, so I cannot assume connection data for specific VPN's or networks. Since the connection to officenetwork is a VPN, I need to ignore it, and only store and reference the settings for homenetwork. However, if I'm at home, and I use a VPN to connect to officenetwork, examining NetworkListManagerClass based off the NLM_ENUM_NETWORK_CONNECTED status will show both homenetwork and officenetwork. Similarly, if I'm at home, I should be able to see homenetwork, and store and reference a different set of settings specific to that network. My application should know that officenetwork is my current local network, and will store and reference settings specific to that network. If I'm at work, I can see I'm connected to officenetwork by examining NetworkListManagerClass based off the NLM_ENUM_NETWORK_CONNECTED status. We'll call my home network "homenetwork". We'll call my work network "officenetwork". I need to be able to track details about the network that the non-VPN interfaces are connected to. However, it isn't enough for me to just know that an interface is or is not a VPN. If (n.NetworkInterfaceType = NetworkInterfaceType.Tunnel || n.NetworkInterfaceType = NetworkInterfaceType.PPP) I believe I can determine if a connection adapter is for a VPN by examining the NetworkInterfaceType of the NetworkInterface class: NetworkInterface interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(n => n.OperationalStatus = OperationalStatus.Up).ToArray() įoreach (NetworkInterface n in interfaces) ![]() Var connectedNetworks = manager.GetNetworks(NLM_ENUM_NETWORK.NLM_ENUM_NETWORK_CONNECTED).Cast() I need to be able to identify the network(s) being connected to, as well, so I'm using NetworkListManagerClass() to build a list of current connections: var manager = new NetworkListManagerClass() I'm trying to track all current network connections at run time, but I want to exclude VPN connections. ![]()
0 Comments
Leave a Reply. |