-api-id | -api-type |
---|---|
M:Windows.Devices.Display.DisplayMonitor.FromIdAsync(System.String) |
winrt method |
Asynchronously creates a DisplayMonitor object for the specified device identifier (a string containing a PnP device instance path). See the code example below.
Note
The argument must be a device identifier, and not a device interface identifier. If you have a device interface identifier (which is likely), then call FromInterfaceIdAsync instead. For more details, see DeviceInformation.Id.
The monitor device identifier. See DeviceInformation.Id.
An asynchronous create operation.
using namespace winrt;
using namespace Windows::Devices::Display;
using namespace Windows::Devices::Enumeration;
using namespace Windows::Foundation;
IAsyncAction EnumerateDisplayMonitorsUsingAdditionalPropertiesAsync()
{
winrt::hstring propertyName = L"System.Devices.DeviceInstanceId";
auto const dis{ co_await DeviceInformation::FindAllAsync(DisplayMonitor::GetDeviceSelector(), { propertyName }) };
for (auto const& deviceInformation : dis)
{
WINRT_ASSERT(deviceInformation.Kind() == DeviceInformationKind::DeviceInterface);
DisplayMonitor displayMonitor{ co_await DisplayMonitor::FromIdAsync(winrt::unbox_value<winrt::hstring>(deviceInformation.Properties().Lookup(propertyName))) };
}
}