ProximityDevice.DeviceId Eigenschaft

Definition

Ruft die DeviceInformation-ID für ein Näherungsgerät ab.

public:
 property Platform::String ^ DeviceId { Platform::String ^ get(); };
winrt::hstring DeviceId();
public string DeviceId { get; }
var string = proximityDevice.deviceId;
Public ReadOnly Property DeviceId As String

Eigenschaftswert

String

Platform::String

winrt::hstring

Die DeviceInformation-ID für ein Näherungsgerät.

Windows-Anforderungen

App-Funktionen
ID_CAP_PROXIMITY [Windows Phone] proximity ID_CAP_PROXIMITY [Windows Phone]

Beispiele

private async void QueryDeviceProperties()
{
    // Include the proximity properties key
    var propertiesToRetrieve = new List<String> {"{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"};

    var defaultProximityDevice =
        Windows.Networking.Proximity.ProximityDevice.GetDefault();

    if (defaultProximityDevice != null)
    {
        var devInfo = await Windows.Devices.Enumeration.DeviceInformation.CreateFromIdAsync(
            defaultProximityDevice.DeviceId, propertiesToRetrieve);

        if (devInfo.Properties.ContainsKey("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"))
        {
            var proximityCapabilities =
                devInfo.Properties["{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"] as string[];
            if (proximityCapabilities.Contains("StandardNfc"))
            {
                // This proximity device supports NFC
            }
        }
    }
}
Private Async Sub QueryDeviceProperties()
    ' Include the proximity properties key
    Dim propertiesToRetrieve = New List(Of String) From {"{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"}

    Dim defaultProximityDevice =
        Windows.Networking.Proximity.ProximityDevice.GetDefault()

    If defaultProximityDevice IsNot Nothing Then
        Dim devInfo = Await Windows.Devices.Enumeration.DeviceInformation.CreateFromIdAsync(
            defaultProximityDevice.DeviceId, propertiesToRetrieve)

        If devInfo.Properties.ContainsKey("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2") Then
            Dim proximityCapabilities =
                TryCast(devInfo.Properties("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"), String())

            If proximityCapabilities.Contains("StandardNfc") Then
                ' This proximity device supports NFC
            End If
        End If
    End If
End Sub

Hinweise

Wenn Ihr Computer Näherung unterstützt und ein NFC-Gerät installiert ist, was in der Regel der Fall ist, gibt die GetDefault-Methode das Gerät zurück, das NFC unterstützt. Sie können auch ermitteln, ob auf Ihrem Computer ein NFC-Gerät installiert ist, indem Sie die Geräteinformationen für die Eigenschaft "{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2" abfragen. Im DeviceInformation.Properties-Objekt , das von der Abfrage zurückgegeben wurde, enthält der Wert für den Schlüssel "{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2" und ein Array von Zeichenfolgen, die die Funktionen des Näherungsgeräts beschreiben. Wenn eine der Zeichenfolgen "StandardNfc" lautet, unterstützt das Gerät NFC-Protokolle wie NDEF. Weitere Informationen zum Abfragen der Eigenschaften eines Geräts finden Sie unter Abrufen zusätzlicher Eigenschaften für ein Gerät oder PnP-Objekt.

Gilt für:

Weitere Informationen