Compartilhar via


HardwareIdentification Classe

Definição

Fornece a capacidade de obter um identificador de hardware que representa o hardware atual.

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
Herança
Object Platform::Object IInspectable HardwareIdentification
Atributos

Requisitos do Windows

Família de dispositivos
Windows Desktop Extension SDK (introduzida na 10.0.10240.0)
Windows Mobile Extension SDK (introduzida na 10.0.10240.0)
Windows 10 Anniversary Edition (introduzida na 10.0.14393.0)
API contract
Windows.System.Profile.ProfileHardwareTokenContract (introduzida na v1.0)

Exemplos

O código a seguir mostra como obter a ID de hardware de um dispositivo usando GetPackageSpecificToken.

// 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

Comentários

Consulte Diretrizes sobre como usar a ASHWID (ID de Hardware Específica do Aplicativo) para implementar a lógica do aplicativo por dispositivo para obter mais informações.

Observação

Essa classe não é ágil, o que significa que você precisa considerar seu modelo de threading e comportamento de marshaling. Para obter mais informações, consulte Threading and Marshaling (C++/CX) e Using Windows Runtime objects in a multithreaded environment (.NET).

Métodos

GetPackageSpecificToken(IBuffer)

Obtém um ASHWID (identificador de hardware) que representa o hardware atual. O ASHWID retornado será diferente para cada pacote de aplicativos. Em outras palavras, essa API retornará identificadores diferentes quando chamada por dois aplicativos de pacotes diferentes. Ele retornará o mesmo identificador quando chamado por dois aplicativos que fazem parte do mesmo pacote.

Aplica-se a

Confira também