語言

CngKey.GetProperty(String, CngPropertyOptions) 方法

定義

獲得一個屬性,並賦予名稱和一組屬性選項。

public:
 System::Security::Cryptography::CngProperty GetProperty(System::String ^ name, System::Security::Cryptography::CngPropertyOptions options);
public System.Security.Cryptography.CngProperty GetProperty(string name, System.Security.Cryptography.CngPropertyOptions options);
[System.Security.SecurityCritical]
public System.Security.Cryptography.CngProperty GetProperty(string name, System.Security.Cryptography.CngPropertyOptions options);
member this.GetProperty : string * System.Security.Cryptography.CngPropertyOptions -> System.Security.Cryptography.CngProperty
[<System.Security.SecurityCritical>]
member this.GetProperty : string * System.Security.Cryptography.CngPropertyOptions -> System.Security.Cryptography.CngProperty
Public Function GetProperty (name As String, options As CngPropertyOptions) As CngProperty

參數

name
String

目標房產的名稱。

options
CngPropertyOptions

以位元組合列出指定屬性選項的列舉值。

傳回

一個包含指定屬性原始值的物件。

屬性

例外狀況

name 是 null。

其他所有錯誤。

備註

此方法的目的是回傳金鑰任意屬性的值。 典型的擷取方式是使用類別提供的 CngKey 屬性存取器。 CngKey 提供多個(但非全部)屬性的包裝器。 此 GetProperty 方法主要用於存取未包裝的屬性價值。

此方法適用於以下情況:

  • 作業系統的新版本支援一個沒有封裝器的新一代密碼學(CNG)金鑰特性。

  • 你要在金鑰中加入自訂屬性。

該 options 參數特別用來表示以下情況:

  • 無論物業是內建還是客製化。

  • 是否應該以金鑰持續保留該屬性。

這些選項必須與該房產設定的價值相符,否則該房產將無法被找到。

CryptographicException 若找不到該屬性,則會被丟棄。 你應該先呼叫方法 HasProperty 以避免異常,而不是把方法呼叫包裝成區 try/catch 塊。

適用於