Network​Information Network​Information Network​Information Class

Definition

Provides access to network connection information for the local machine.

public : static class NetworkInformationpublic static class NetworkInformationPublic Static Class NetworkInformation
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

For examples of how NetworkInformation class methods are implemented, see Quickstart: Retrieving network connection information.

Methods

FindConnectionProfilesAsync(ConnectionProfileFilter) FindConnectionProfilesAsync(ConnectionProfileFilter) FindConnectionProfilesAsync(ConnectionProfileFilter)

Returns an array of ConnectionProfile objects that match the filtering criteria defined by ConnectionProfileFilter.

public : static IAsyncOperation<IVectorView<ConnectionProfile>> FindConnectionProfilesAsync(ConnectionProfileFilter pProfileFilter)public static IAsyncOperation<IReadOnlyList<ConnectionProfile>> FindConnectionProfilesAsync(ConnectionProfileFilter pProfileFilter)Public Static Function FindConnectionProfilesAsync(pProfileFilter As ConnectionProfileFilter) As IAsyncOperation( Of IReadOnlyListConnectionProfile )
Parameters
pProfileFilter
ConnectionProfileFilter ConnectionProfileFilter ConnectionProfileFilter

Provides the filtering criteria.

Returns
IAsyncOperation<IVectorView<ConnectionProfile>> IAsyncOperation<IReadOnlyList<ConnectionProfile>> IAsyncOperation<IReadOnlyList<ConnectionProfile>>

An array of ConnectionProfile objects.

Attributes
See Also

GetConnectionProfiles() GetConnectionProfiles() GetConnectionProfiles()

Gets a list of profiles for connections, active or otherwise, on the local machine.

public : static IVectorView<ConnectionProfile> GetConnectionProfiles()public static IReadOnlyList<ConnectionProfile> GetConnectionProfiles()Public Static Function GetConnectionProfiles() As IReadOnlyList( Of ConnectionProfile )
Returns
IVectorView<ConnectionProfile> IReadOnlyList<ConnectionProfile> IReadOnlyList<ConnectionProfile>

An array of ConnectionProfile objects.

Attributes

Remarks

The following example demonstrates how to retrieve a ConnectionProfile. The function calls getConnectionProfiles to retrieve all available connections on a device and display using a list. Alternatively, your app can call getInternetConnectionProfile to retrieve the ConnectionProfile representing the connection currently used for Internet connectivity.

function DisplayConnectionProfileList() {
    var profileList = "";
    var ConnectionProfiles = networkInfo.getConnectionProfiles();
        if (ConnectionProfiles.length !== 0) {
            for (var i = 0; i < ConnectionProfiles.length; i++) {

                //Display Connection profile info for each profile by passing it
                                                                //to a function that accesses and displays the connection properties
                profileList += getConnectionProfileInfo(ConnectionProfiles[i]);
                profileList += "-------------------------\n\r";
            }
            mySample.displayStatus(profileList);
        }
        else {
            mySample.displayStatus("No profiles found");
        }
    }

    catch (e) {
        mySample.displayError("Exception Caught: " + e + "\n\r");
    }
}

For additional examples of how NetworkInformation class methods are implemented to retrieve connection profiles, see Quickstart: Retrieving network connection information.

GetHostNames() GetHostNames() GetHostNames()

Gets a list of host names associated with the local machine.

public : static IVectorView<HostName> GetHostNames()public static IReadOnlyList<HostName> GetHostNames()Public Static Function GetHostNames() As IReadOnlyList( Of HostName )
Returns
IVectorView<HostName> IReadOnlyList<HostName> IReadOnlyList<HostName>

An array of host names for the local machine.

Attributes

GetInternetConnectionProfile() GetInternetConnectionProfile() GetInternetConnectionProfile()

Gets the connection profile associated with the internet connection currently used by the local machine.

public : static ConnectionProfile GetInternetConnectionProfile()public static ConnectionProfile GetInternetConnectionProfile()Public Static Function GetInternetConnectionProfile() As ConnectionProfile
Returns

The profile for the connection currently used to connect the machine to the Internet, or null if there is no connection profile with a suitable connection.

Attributes

Remarks

To be notified of changes in connectivity, register a handler with the NetworkStatusChanged event. When a notification is received of a network status change, call the GetInternetConnectionProfile method to get the current connection profile which can then be stored for later use when needed.

The following example demonstrates how to retrieve a ConnectionProfile. The function calls getInternetConnectionProfile to retrieve the ConnectionProfile representing the connection currently used for Internet connectivity. Alternatively, your app can call getConnectionProfiles to retrieve all available connections on a device.


var networkInfo = Windows.Networking.Connectivity.NetworkInformation;

//Retrieve the ConnectionProfile
var internetConnectionProfile = networkInfo.getInternetConnectionProfile();

//Pass the returned object to a function that accesses the connection data  
var connectionProfileInfo = getConnectionProfileInfo(internetConnectionProfile);

using namespace Windows::Networking::Connectivity;

//Retrieve the ConnectionProfile
ConnectionProfile^ InternetConnectionProfile = NetworkInformation::GetInternetConnectionProfile();

//Pass the returned object to a function that accesses the connection data        
String^ strConnectionProfileInfo = GetConnectionProfileInfo(InternetConnectionProfile);

using Windows.Networking.Connectivity;

//Retrieve the ConnectionProfile
string connectionProfileInfo = string.Empty;
ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

//Pass the returned object to a function that accesses the connection data  
connectionProfileInfo = GetConnectionProfileInfo(InternetConnectionProfile);

If more than one connection profile is currently connecting the machine to the internet, the preferred profile is returned by this method. The preferred profile represents the connection that is the most likely to be used when sending and receiving traffic to and from the internet.

For additional examples of how NetworkInformation class methods are implemented to retrieve connection profiles, see Quickstart: Retrieving network connection information.

GetLanIdentifiers() GetLanIdentifiers() GetLanIdentifiers()

Gets an array of LanIdentifier objects that contain locality information for each NetworkAdapter object that currently connected to a network.

public : static IVectorView<LanIdentifier> GetLanIdentifiers()public static IReadOnlyList<LanIdentifier> GetLanIdentifiers()Public Static Function GetLanIdentifiers() As IReadOnlyList( Of LanIdentifier )
Returns
IVectorView<LanIdentifier> IReadOnlyList<LanIdentifier> IReadOnlyList<LanIdentifier>

An array of LanIdentifier objects.

Attributes

Remarks

For examples of how to retrieve LanIdentifier objects and access the information they represent, see How to retrieve network adapter and locality information.

GetProxyConfigurationAsync(Uri) GetProxyConfigurationAsync(Uri) GetProxyConfigurationAsync(Uri)

Gets proxy configuration for a connection using the specified URI.

Note

This class method is not supported on Windows Phone.

public : static IAsyncOperation<ProxyConfiguration> GetProxyConfigurationAsync(Uri uri)public static IAsyncOperation<ProxyConfiguration> GetProxyConfigurationAsync(Uri uri)Public Static Function GetProxyConfigurationAsync(uri As Uri) As IAsyncOperation( Of ProxyConfiguration )
Parameters
uri
Uri Uri Uri

The proxy configuration URI.

Returns
Attributes

Remarks

The uri parameter passed to the GetProxyConfigurationAsync method should contain a hostname or IP address for the target endpoint and service name, port number, or protocol scheme.

If the GetProxyConfigurationAsync method is successful, a ProxyConfiguration object for the specified uri parameter is returned by the IAsyncOperation(ProxyConfiguration) handler.

In a Windows Store app, the StreamSocket class supports connecting to a remote endpoint when proxies are required to complete the connection. This support for proxies is automatic and transparent to the app. For more detailed information, see the remarks on Support for proxies in the StreamSocket class reference.

GetSortedEndpointPairs(IIterable<EndpointPair>, HostNameSortOptions) GetSortedEndpointPairs(IIterable<EndpointPair>, HostNameSortOptions) GetSortedEndpointPairs(IIterable<EndpointPair>, HostNameSortOptions)

Gets a sorted list of EndpointPair objects.

public : static IVectorView<EndpointPair> GetSortedEndpointPairs(IIterable<EndpointPair> destinationList, HostNameSortOptions sortOptions)public static IReadOnlyList<EndpointPair> GetSortedEndpointPairs(IEnumerable<EndpointPair> destinationList, HostNameSortOptions sortOptions)Public Static Function GetSortedEndpointPairs(destinationList As IEnumerable<EndpointPair>, sortOptions As HostNameSortOptions) As IReadOnlyList( Of EndpointPair )
Parameters
destinationList
IIterable<EndpointPair> IEnumerable<EndpointPair> IEnumerable<EndpointPair>

A list of EndpointPair objects to be sorted.

sortOptions
HostNameSortOptions HostNameSortOptions HostNameSortOptions

Indicates sorting options for the returned array.

Returns
IVectorView<EndpointPair> IReadOnlyList<EndpointPair> IReadOnlyList<EndpointPair>

A sorted array of EndpointPair objects.

Attributes

Events

NetworkStatusChanged NetworkStatusChanged NetworkStatusChanged

Occurs when the network status changes for a connection.

public : static event NetworkStatusChangedEventHandler NetworkStatusChangedpublic static event NetworkStatusChangedEventHandler NetworkStatusChangedPublic Static Event NetworkStatusChanged
Attributes

See Also