DisplayMonitor.FromIdAsync(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
以非同步方式為指定的裝置識別碼建立 DisplayMonitor 物件, (包含 PnP 裝置實例路徑的字串) 。 請參閱下列程式碼範例。
注意
引數必須是裝置識別碼,而不是裝置介面識別碼。 如果您有可能) (裝置介面識別碼,請改為呼叫 FromInterfaceIdAsync 。 如需詳細資訊,請參閱 DeviceInformation.Id。
public:
static IAsyncOperation<DisplayMonitor ^> ^ FromIdAsync(Platform::String ^ deviceId);
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<DisplayMonitor> FromIdAsync(winrt::hstring const& deviceId);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<DisplayMonitor> FromIdAsync(string deviceId);
function fromIdAsync(deviceId)
Public Shared Function FromIdAsync (deviceId As String) As IAsyncOperation(Of DisplayMonitor)
參數
- deviceId
-
String
Platform::String
winrt::hstring
監視裝置識別碼。 請參閱 DeviceInformation.Id。
傳回
非同步建立作業。
- 屬性
範例
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))) };
}
}