Network List Manager (System.Net.NetworkInformation)
The Network List Manager (NLM) API provides programmatic access to network connectivity information on a computer. It allows applications to retrieve details about the networks connected to the system, their properties, and their connectivity status. This API is crucial for applications that need to adapt their behavior based on the network environment, such as adjusting resource usage, managing connections, or implementing network-aware features.
Introduction
The Network List Manager allows you to:
- Enumerate and retrieve information about currently connected networks.
- Determine the connectivity status and type of networks (e.g., Internet, Home, Public).
- Monitor changes in network connectivity and properties.
- Manage network connections and their associated profiles.
Classes
CLGlobalNetworkProperties
Represents global network properties.
Namespace: NLM
Assembly: NetworkListManager.dll
Remarks
This class provides static methods and properties for accessing system-wide network settings and information.
CLNetwork
Represents a network entity.
Namespace: NLM
Assembly: NetworkListManager.dll
Remarks
Instances of this class can be obtained from CLNetworkListManager.
CLNetworkConnection
Represents a connection to a network.
Namespace: NLM
Assembly: NetworkListManager.dll
Remarks
This class provides properties related to a specific network connection, such as its adapter and connectivity status.
CLNetworkListManager
Manages the list of networks connected to the system.
Namespace: NLM
Assembly: NetworkListManager.dll
Remarks
This is the primary class for interacting with the Network List Manager API. It allows enumeration of networks and registration for network change notifications.
CLNetworkPropertyChangeNotify
Callback interface for network property change notifications.
Namespace: NLM
Assembly: NetworkListManager.dll
Remarks
Implement this interface to receive notifications when network properties change.
Interfaces
INetwork
Represents a network.
Namespace: NLM
Remarks
Provides methods to get properties of a network.
Methods
GetNetworkConnectivity
NLM_CONNECTIVITY GetNetworkConnectivity();Return Value
A NLM_CONNECTIVITY enumeration value indicating the network's connectivity status.
GetNetworkId
Guid GetNetworkId();Return Value
The unique identifier (GUID) of the network.
GetName
string GetName();Return Value
The friendly name of the network.
INetworkConnection
Represents a connection to a network.
Namespace: NLM
Remarks
Provides details about a specific network connection.
Methods
GetConnectionId
Guid GetConnectionId();Return Value
The unique identifier (GUID) of the connection.
GetAdapter
Guid GetAdapter();Return Value
The GUID of the network adapter associated with this connection.
INetworkListManager
Manages the list of networks.
Namespace: NLM
Remarks
This interface is the main entry point for interacting with network list services.
Methods
GetNetworkById
INetwork GetNetworkById(Guid networkId);Parameters
networkId: The GUID of the network to retrieve.
Return Value
An INetwork object representing the network, or null if not found.
GetNetworks
IEnumNetworks GetNetworks(NLM_NETWORK_CATEGORY category);Parameters
category: Specifies the category of networks to retrieve (e.g., Public, Private, All).
Return Value
An enumeration of INetwork objects matching the specified category.
Enumerations
NLM_CONNECTIVITY
Specifies the connectivity status of a network.
Namespace: NLM
| Member | Value | Description |
|---|---|---|
NLM_CONNECTIVITY_DISCONNECTED | 0 | The network is disconnected. |
NLM_CONNECTIVITY_PARTIAL | 1 | The network has partial connectivity (e.g., local network access but no Internet). |
NLM_CONNECTIVITY_INTERNET_ACCESS | 2 | The network has Internet access. |
NLM_CONNECTIVITY_WEBWALL | 4 | The network is behind a web wall (e.g., requires captive portal authentication). |
NLM_CONNECTIVITY_ANY | 0xFFFFFFFF | Any connectivity status. |
NLM_NETWORK_CATEGORY
Specifies the category assigned to a network.
Namespace: NLM
| Member | Value | Description |
|---|---|---|
NLM_NETWORK_CATEGORY_PUBLIC | 0 | Represents a public network (e.g., coffee shop, airport). Firewall is typically enabled. |
NLM_NETWORK_CATEGORY_PRIVATE | 1 | Represents a private network (e.g., home, work). Firewall is typically disabled or less restrictive. |
NLM_NETWORK_CATEGORY_DOMAIN_JOINED | 2 | The network is joined to a domain. |
Structures
NLM_NETWORK_PROPERTY_DATA
Contains data for a network property.
Namespace: NLM
| Member | Type | Description |
|---|---|---|
type | NLM_NETWORK_PROPERTY_TYPE | The type of the network property. |
data | void* | Pointer to the property data. The interpretation depends on the type. |
Requirements
Header: NetworkListManager.h
Library: Nlm.lib
DLL: NetworkListManager.dll
Minimum supported client: Windows 7
Minimum supported server: Windows Server 2008 R2