Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 2.14 KB

displaymonitor_frominterfaceidasync_1923441009.md

File metadata and controls

48 lines (37 loc) · 2.14 KB
-api-id -api-type
M:Windows.Devices.Display.DisplayMonitor.FromInterfaceIdAsync(System.String)
winrt method

Windows.Devices.Display.DisplayMonitor.FromInterfaceIdAsync

-description

Asynchronously creates a DisplayMonitor object for the specified monitor interface identifier (a string containing a PnP device interface path). See the code example below.

Note

If you call DeviceInformation.FindAllAsync, passing the Advanced Query Syntax (AQS) device interface selector string returned by DisplayMonitor.GetDeviceSelector, then you will retrieve a collection of DeviceInformation objects that describe monitor interfaces (rather than monitor devices). Accessing the DeviceInformation.Id property on one of those objects retrieves a monitor interface identifier, which you can pass to DisplayMonitor.FromInterfaceIdAsync. See the code example below.

Most Win32 APIs that provide a monitor identifier actually provide the monitor interface identifier (and not the device identifier).

-parameters

-param deviceInterfaceId

The monitor interface identifier

-returns

An asynchronous create operation.

-remarks

-see-also

-examples

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