HidDevice.FromIdAsync(String, FileAccessMode) Method

Definition

Opens a handle to the device identified by the deviceId parameter. The access type is specified by the accessMode parameter.

public:
 static IAsyncOperation<HidDevice ^> ^ FromIdAsync(Platform::String ^ deviceId, FileAccessMode accessMode);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<HidDevice> FromIdAsync(winrt::hstring const& deviceId, FileAccessMode const& accessMode);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<HidDevice> FromIdAsync(string deviceId, FileAccessMode accessMode);
function fromIdAsync(deviceId, accessMode)
Public Shared Function FromIdAsync (deviceId As String, accessMode As FileAccessMode) As IAsyncOperation(Of HidDevice)

Parameters

deviceId
String

Platform::String

winrt::hstring

The DeviceInformation ID that identifies the HID device.

accessMode
FileAccessMode

Specifies the access mode. The supported access modes are Read and ReadWrite.

Returns

A HidDevice object. If HID device capabilities are absent or incorrect, this will be null.

Attributes

Remarks

The first time this method is invoked by a store app, it should be called from a UI thread in order to display the consent prompt. After the user has granted consent, the method can be invoked from any application thread.

The application manifest must declare HID device capabilities before invoking this method. If HID device capabilities are missing or incorrectly specified, the returned value will be null and no exception will be thrown.

The device must be opened with FileAccessMode.ReadWrite to call SendOutputReportAsync or the call will fail with a System.UnauthorizedAccessException: Access is denied. (Excep_FromHResult 0x80070005) exception. To call SendFeatureReportAsync, GetFeatureReportAsync or GetInputReportAsync, the device must be opened with either FileAccessMode.Read or FileAccessMode.ReadWrite

Applies to

See also