NetworkInformation.GetInternetConnectionProfile 메서드

정의

로컬 컴퓨터에서 현재 사용하는 기본 인터페이스와 연결된 연결 프로필을 검색합니다. 기본 인터페이스는 인터넷 트래픽을 보내거나 받을 가능성이 가장 높은 인터페이스입니다. 즉, 반환된 프로필은 인터넷에 액세스할 수 있거나 인터넷에 액세스하지 못할 수 있습니다.

public:
 static ConnectionProfile ^ GetInternetConnectionProfile();
 static ConnectionProfile GetInternetConnectionProfile();
public static ConnectionProfile GetInternetConnectionProfile();
function getInternetConnectionProfile()
Public Shared Function GetInternetConnectionProfile () As ConnectionProfile

반환

기본 설정 인터페이스와 연결된 연결 프로필이거나, 적절한 연결이 있는 연결 프로필이 없는 경우 null입니다.

설명

연결 변경에 대한 알림을 받도록 NetworkStatusChanged 이벤트에 처리기를 등록합니다. 네트워크 상태 변경 알림이 수신되면 GetInternetConnectionProfile 메서드를 호출하여 현재 연결 프로필을 가져와 필요할 때 나중에 사용할 수 있도록 저장할 수 있습니다.

다음 예제에서는 ConnectionProfile을 검색하는 방법을 보여 줍니다. 함수는 GetInternetConnectionProfile 을 호출하여 현재 인터넷 연결에 가장 자주 사용되는 연결을 나타내는 ConnectionProfile 을 검색합니다. 또는 앱에서 GetConnectionProfiles 를 호출하여 디바이스에서 사용 가능한 모든 연결을 검색할 수 있습니다.

참고

아래 코드에서 GetConnectionProfileInfo 메서드를 구현하고 연결 프로필을 검색하기 위해 NetworkInformation 클래스 메서드를 구현하는 방법에 대한 추가 예제는 빠른 시작: 네트워크 연결 정보 검색을 참조하세요.

using Windows.Networking.Connectivity;

// Retrieve the ConnectionProfile.
ConnectionProfile internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

// Pass the returned object to a function that accesses the connection data.
string connectionProfileInfo = GetConnectionProfileInfo(internetConnectionProfile);
#include <winrt/Windows.Networking.Connectivity.h>
using namespace winrt;

std::wstring GetConnectionProfileInfo(Windows::Networking::Connectivity::ConnectionProfile const& connectionProfile)
{
    ...
}

int main()
{
    winrt::init_apartment();

    // Retrieve the ConnectionProfile.
    auto internetConnectionProfile{ Windows::Networking::Connectivity::NetworkInformation::GetInternetConnectionProfile() };

    // Pass the returned object to a function that accesses the connection data.
    std::wstring strConnectionProfileInfo{ 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);

현재 둘 이상의 연결 프로필이 컴퓨터에 인터넷에 연결되고 있는 경우 이 메서드에서 기본 설정 프로필이 반환됩니다. 기본 설정 프로필은 인터넷에서 트래픽을 보내고 받을 때 사용할 가능성이 가장 높은 연결을 나타냅니다.

적용 대상