Share via


DisplayMonitor.FromInterfaceIdAsync(String) メソッド

定義

指定したモニター インターフェイス識別子 (PnP デバイス インターフェイス パスを含む文字列) の DisplayMonitor オブジェクトを非同期に作成します。 以下のコード例を参照してください。

注意

DisplayMonitor.GetDeviceSelector によって返される高度なクエリ構文 (AQS) デバイス インターフェイス セレクター文字列を渡して DeviceInformation.FindAllAsync を呼び出すと、(モニター デバイスではなく) モニター インターフェイスを記述する DeviceInformation オブジェクトのコレクションを取得します。 これらのオブジェクトの DeviceInformation.Id プロパティにアクセスすると、 DisplayMonitor.FromInterfaceIdAsync に渡すことができるモニター インターフェイス識別子が取得されます。 以下のコード例を参照してください。

モニター識別子を提供するほとんどの Win32 API は、実際には (デバイス識別子ではなく) モニター インターフェイス識別子を提供します。

public:
 static IAsyncOperation<DisplayMonitor ^> ^ FromInterfaceIdAsync(Platform::String ^ deviceInterfaceId);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<DisplayMonitor> FromInterfaceIdAsync(winrt::hstring const& deviceInterfaceId);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<DisplayMonitor> FromInterfaceIdAsync(string deviceInterfaceId);
function fromInterfaceIdAsync(deviceInterfaceId)
Public Shared Function FromInterfaceIdAsync (deviceInterfaceId As String) As IAsyncOperation(Of DisplayMonitor)

パラメーター

deviceInterfaceId
String

Platform::String

winrt::hstring

モニター インターフェイス識別子

戻り値

非同期の作成操作。

属性

using namespace winrt;
using namespace Windows::Devices::Display;
using namespace Windows::Devices::Enumeration;
using namespace Windows::Foundation;

IAsyncAction EnumerateDisplayMonitorsAsync()
{
    auto const dis{ co_await DeviceInformation::FindAllAsync(DisplayMonitor::GetDeviceSelector()) };

    for (auto const& deviceInformation : dis)
    {
        WINRT_ASSERT(deviceInformation.Kind() == DeviceInformationKind::DeviceInterface);
        DisplayMonitor displayMonitor{ co_await DisplayMonitor::FromInterfaceIdAsync(deviceInformation.Id()) };
    }
}

適用対象