-api-id | -api-type |
---|---|
T:Windows.System.Profile.HardwareIdentification |
winrt class |
Provides the ability to obtain a hardware identifier that represents the current hardware.
See Guidance on using the App Specific Hardware ID (ASHWID) to implement per-device app logic for more information.
Note
This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
The following code shows how to get the hardware id of a device using 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
Guidance on using the App Specific Hardware ID (ASHWID) to implement per-device app logic