NetworkInformation.GetConnectionProfiles 方法

定義

取得本機電腦上連線的配置檔案清單,或為使用中或其他設定檔。

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

傳回

ConnectionProfile物件的陣列。

備註

下列範例示範如何擷取 ConnectionProfile。 函式會呼叫 getConnectionProfiles ,以擷取裝置上的所有可用連線,並使用清單顯示。 或者,您的應用程式可以呼叫 getInternetConnectionProfile 來擷取代表目前用於網際網路連線之連線的 ConnectionProfile

注意 如需下列程式碼中 getConnectionProfileInfo 方法的實作,以及如何實作 NetworkInformation 類別方法以擷取連線設定檔的其他範例,請參閱 快速入門:擷取網路連線資訊

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

適用於