HardwareIdentification 类

定义

提供获取表示当前硬件的硬件标识符的功能。

public ref class HardwareIdentification abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.System.Profile.ProfileHardwareTokenContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
class HardwareIdentification final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.System.Profile.ProfileHardwareTokenContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
public static class HardwareIdentification
Public Class HardwareIdentification
继承
Object Platform::Object IInspectable HardwareIdentification
属性

Windows 要求

设备系列
Windows Desktop Extension SDK (在 10.0.10240.0 中引入)
Windows Mobile Extension SDK (在 10.0.10240.0 中引入)
Windows 10 Anniversary Edition (在 10.0.14393.0 中引入)
API contract
Windows.System.Profile.ProfileHardwareTokenContract (在 v1.0 中引入)

示例

以下代码演示如何使用 GetPackageSpecificToken 获取设备的硬件 ID。

// nonce is an IBuffer object that would be sent from the cloud service.
HardwareToken packageSpecificToken;

packageSpecificToken =  Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(nonce);

// hardware id, signature, certificate IBuffer objects 
// that can be accessed through properties.
IBuffer hardwareId  = packageSpecificToken.Id;
IBuffer signature = packageSpecificToken.Signature;
IBuffer certificate = packageSpecificToken.Certificate;
void MainPage::DefaultLaunch()
{
    // nonce is a value of type Windows::Storage::Streams::IBuffer, which
    // would be sent from the cloud service in a real scenario.
    Windows::System::Profile::HardwareToken packageSpecificToken{
        Windows::System::Profile::HardwareIdentification::GetPackageSpecificToken(nonce) };

    // hardware id, signature, certificate IBuffer objects 
    // that can be accessed through properties.
    Windows::Storage::Streams::IBuffer hardwareId{ packageSpecificToken.Id() };
    Windows::Storage::Streams::IBuffer signature{ packageSpecificToken.Signature() };
    Windows::Storage::Streams::IBuffer certificate{ packageSpecificToken.Certificate() };
}
// nonce is an IBuffer object that would be sent from the cloud service.
HardwareToken^ packageSpecificToken;

packageSpecificToken =  Windows::System::Profile::HardwareIdentification::GetPackageSpecificToken(nonce);

// hardware id, signature, certificate IBuffer objects 
// that can be accessed through properties.
IBuffer^ hardwareId = packageSpecificToken->Id;
IBuffer^ signature = packageSpecificToken->Signature;
IBuffer^ certificate = packageSpecificToken->Certificate;
// nonce is an IBuffer object that would be sent from the cloud service.
Dim packageSpecificToken As Windows.System.Profile.HardwareToken

packageSpecificToken = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(nonce)

// hardware id, signature, certificate IBuffer objects 
// that can be accessed through properties.
Dim hardwareId As Windows.Storage.Streams.IBuffer = packageSpecificToken.Id
Dim signature As Windows.Storage.Streams.IBuffer = packageSpecificToken.Signature
Dim certificate As Windows.Storage.Streams.IBuffer = packageSpecificToken.Certificate

注解

有关详细信息 ,请参阅有关使用特定于应用的硬件 ID (ASHWID) 实现每设备应用逻辑的指南

注意

此类不是敏捷类,这意味着需要考虑其线程模型和封送处理行为。 有关详细信息,请参阅线程处理和封送处理 (C++/CX) 在多线程环境中使用 Windows 运行时 对象 (.NET)

方法

GetPackageSpecificToken(IBuffer)

获取表示当前硬件 (ASHWID) 的硬件标识符。 对于每个应用程序包,返回的 ASHWID 将有所不同。 换句话说,当两个应用从不同的包调用时,此 API 将返回不同的标识符。 当由属于同一包的两个应用调用时,它将返回相同的标识符。

适用于

另请参阅