NetworkInformation NetworkInformation NetworkInformation NetworkInformation Class

Definition

Provides access to network connection information for the local machine.

public static class NetworkInformationpublic static class NetworkInformationPublic Static Class NetworkInformationpublic static class NetworkInformation
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
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) 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<IVectorView<ConnectionProfile>> FindConnectionProfilesAsync(ConnectionProfileFilter pProfileFilter)Public Static Function FindConnectionProfilesAsync(pProfileFilter As ConnectionProfileFilter) As IAsyncOperation( Of IVectorViewConnectionProfile )public static IAsyncOperation<IVectorView<ConnectionProfile>> FindConnectionProfilesAsync(ConnectionProfileFilter pProfileFilter)
Parameters
Returns

An array of ConnectionProfile objects.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetConnectionProfiles() GetConnectionProfiles() GetConnectionProfiles() GetConnectionProfiles()

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

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

An array of ConnectionProfile objects.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The following example demonstrates how to retrieve a ConnectionProfile. The function calls GetInternetConnectionProfile() 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() GetHostNames()

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

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

An array of host names for the local machine.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetInternetConnectionProfile() 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 ConnectionProfilepublic static ConnectionProfile GetInternetConnectionProfile()
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
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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() 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 IVectorView<LanIdentifier> GetLanIdentifiers()Public Static Function GetLanIdentifiers() As IVectorView( Of LanIdentifier )public static IVectorView<LanIdentifier> GetLanIdentifiers()
Returns

An array of LanIdentifier objects.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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) 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 )public static IAsyncOperation<ProxyConfiguration> GetProxyConfigurationAsync(Uri uri)
Parameters
uri
Uri Uri Uri Uri

The proxy configuration URI.

Returns

Information about the connection proxy.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

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

If the GetProxyConfigurationAsync(Uri) method is successful, a ProxyConfiguration object for the specified uri parameter is returned by the IAsyncOperation<TResult> 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) GetSortedEndpointPairs(IIterable<EndpointPair>, HostNameSortOptions)

Gets a sorted list of EndpointPair objects.

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

A list of EndpointPair objects to be sorted.

sortOptions
HostNameSortOptions HostNameSortOptions HostNameSortOptions HostNameSortOptions

Indicates sorting options for the returned array.

Returns

A sorted array of EndpointPair objects.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Events

NetworkStatusChanged NetworkStatusChanged NetworkStatusChanged NetworkStatusChanged

Occurs when the network status changes for a connection.

public static event NetworkStatusChangedEventHandler NetworkStatusChangedpublic static event NetworkStatusChangedEventHandler NetworkStatusChangedPublic Static Event NetworkStatusChangedpublic static event NetworkStatusChangedEventHandler NetworkStatusChanged
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)