Checking Availability Before Attempting Use

Before an application tries to use a network resource, it should determine whether the resource can be accessed through the active network connections. Because network connections are transitory on mobile PCs, it's also important to monitor for changes in network connectivity.

By using the Network Location Awareness Service Provider (NLA) , your application can obtain information about connected networks and monitor for changes in the network environment. The Network Profile service manages a list of network profiles, each of which identifies a network to which the computer has connected. A single network profile can encompass several different types of connections to the same network. For example, both a wired and a wireless connection to a home networking hub can be part of the same network profile. A managed network for a business can have the same network profile regardless of whether the user is connected through a wired connection at the office or through a virtual private network (VPN) connection from home.

By using network profiles, your application can proactively monitor the status of network connectivity and adapt to changes as needed. When an application interacts with network resources, it should do the following:

  • Before it attempts to connect, it should determine whether the network profile that's associated with the resource is active.
  • It should register to be notified when the network configuration changes, so that it can respond appropriately. Notifications are described in Handling Network Transitions Transparently.

Checking for availability

You can use the INetworkListManager::EnumNetworks method to enumerate the network profiles. You can enumerate all networks, those that are currently connected, or those that are disconnected. This method returns a list of network objects that expose the INetwork interface. For more information about the INetwork interface and to see an implementation of one, see Network Awareness on Windows Vista.

Each network profile has a name and description that you can access by using the INetwork::GetName and INetwork::GetDescription methods. You can use the INetwork::GetState method to determine whether the network is connected to the computer and whether the connection has Internet connectivity. Use the INetwork::GetType method to determine whether the network is a managed (domain) network, and whether the user is authenticated on that network.

If your network activity is likely to involve any noticeable delay, you should calculate the probable length of that delay and display feedback in some way, such as a progress bar. For more information, see Provide Options During Lengthy Operations.

Network Location Manager

 

 

Send comments about this topic to Microsoft

Build date: 2/8/2011