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

列舉型別值的位元組合,指定具名屬性的選項。

傳回

物件,包含指定屬性未經處理的值。

屬性

例外狀況

namenull

所有其他錯誤。

備註

這個方法的目的是要傳回索引鍵任意屬性的值。 擷取屬性的一般方式是使用 類別所提供的 CngKey 屬性存取子。 CngKey 提供數個但不是全部屬性的包裝函式。 方法 GetProperty 主要用於存取未包裝的屬性值。

在下列情況下,此方法很有用:

  • 新版本的作業系統支援新的密碼編譯新一代 (CNG) 沒有包裝函式的金鑰屬性。

  • 您會將自訂屬性新增至索引鍵。

參數 options 特別用來指出下列各項:

  • 屬性是內建的,還是自訂的。

  • 屬性是否應該與索引鍵一起保存。

這些選項必須符合屬性設定的值,否則找不到 屬性。

CryptographicException 如果找不到 屬性,則會擲回 。 您應該先呼叫 HasProperty 方法,以避免例外狀況,而不是將方法呼叫包裝在 區塊中 try/catch

適用於