Dela via


NetworkInformation.GetConnectionProfiles Method

Definition

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

public:
 static IVectorView<ConnectionProfile ^> ^ GetConnectionProfiles();
 static IVectorView<ConnectionProfile> GetConnectionProfiles();
public static IReadOnlyList<ConnectionProfile> GetConnectionProfiles();
function getConnectionProfiles()
Public Shared Function GetConnectionProfiles () As IReadOnlyList(Of ConnectionProfile)

Returns

An array of ConnectionProfile objects.

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.

Note For the implementation of the getConnectionProfileInfo method in the code below, and for additional examples of how NetworkInformation class methods are implemented to retrieve connection profiles, see Quickstart: Retrieving network connection information.

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");
    }
}

Applies to