HardwareIdentification 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供取得代表目前硬體的硬體識別碼的能力。
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
- 繼承
- 屬性
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取得裝置的硬體識別碼。
// 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
備註
如需詳細資訊,請參閱 使用應用程式特定硬體識別碼 (ASHWID) 實作個別裝置應用程式邏輯的指引 。
注意
這個類別不是敏捷的,這表示您必須考慮其執行緒模型和封送處理行為。 如需詳細資訊,請參閱執行緒和封送處理 (C++/CX) 和在多執行緒環境中使用 Windows 執行階段 物件 (.NET) 。
方法
GetPackageSpecificToken(IBuffer) |
取得代表目前硬體的硬體識別碼 (ASHWID) 。 傳回的 ASHWID 會針對每個應用程式套件而有所不同。 換句話說,當兩個應用程式從不同的套件呼叫時,此 API 會傳回不同的識別碼。 當兩個屬於相同套件的應用程式呼叫時,它會傳回相同的識別碼。 |