NetworkInformation NetworkInformation NetworkInformation NetworkInformation Class

Provides access to network connection information for the local machine.

Syntax

Declaration

public static class NetworkInformationpublic static class NetworkInformationPublic Static Class NetworkInformation

Remarks

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

Methods summary

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

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

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

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

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

Gets proxy configuration for a connection using the specified URI.

Note

This class method is not supported on Windows Phone.

Gets a sorted list of EndpointPair objects.

Events summary

Occurs when the network status changes for a connection.

Methods

  • FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter)
    FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter)
    FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter)
    FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter)

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

    public static IAsyncOperation<ConnectionProfile>> FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter pProfileFilter)public static IAsyncOperation<ConnectionProfile>> FindConnectionProfilesAsync(Windows.Networking.Connectivity.ConnectionProfileFilter pProfileFilter)Public Static Function FindConnectionProfilesAsync(pProfileFilter As Windows.Networking.Connectivity.ConnectionProfileFilter) As IAsyncOperation( Of ConnectionProfile )

    Parameters

    Returns

  • 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 )

    Returns

    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 )

    Returns

    • An array of host names for the local machine.

  • 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 ConnectionProfile

    Returns

    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 )

    Returns

    • An array of LanIdentifier objects.

    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(Windows.Foundation.Uri)
    GetProxyConfigurationAsync(Windows.Foundation.Uri)
    GetProxyConfigurationAsync(Windows.Foundation.Uri)
    GetProxyConfigurationAsync(Windows.Foundation.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(Windows.Foundation.Uri uri)public static IAsyncOperation<ProxyConfiguration> GetProxyConfigurationAsync(Windows.Foundation.Uri uri)Public Static Function GetProxyConfigurationAsync(uri As Windows.Foundation.Uri) As IAsyncOperation( Of ProxyConfiguration )

    Parameters

    Returns

    • Information about the connection proxy.

    Remarks

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

    If the GetProxyConfigurationAsync(Windows.Foundation.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(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair},Windows.Networking.HostNameSortOptions)
    GetSortedEndpointPairs(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair},Windows.Networking.HostNameSortOptions)
    GetSortedEndpointPairs(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair},Windows.Networking.HostNameSortOptions)
    GetSortedEndpointPairs(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair},Windows.Networking.HostNameSortOptions)

    Gets a sorted list of EndpointPair objects.

    public static IVectorView<EndpointPair> GetSortedEndpointPairs(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair} destinationList,Windows.Networking.HostNameSortOptions sortOptions)public static IVectorView<EndpointPair> GetSortedEndpointPairs(Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair} destinationList,Windows.Networking.HostNameSortOptions sortOptions)Public Static Function GetSortedEndpointPairs(destinationList As Windows.Foundation.Collections.IIterable{Windows.Networking.EndpointPair},sortOptions As Windows.Networking.HostNameSortOptions) As IVectorView( Of EndpointPair )

    Parameters

    Returns

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 NetworkStatusChanged

Attributes

Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.Networking.Connectivity.dll