ICspInformation::InitializeFromType method (certenroll.h)

The InitializeFromType method initializes the object from the default cryptographic provider.

Syntax

HRESULT InitializeFromType(
  [in]           X509ProviderType Type,
  [in, optional] IObjectId        *pAlgorithm,
  [in]           VARIANT_BOOL     MachineContext
);

Parameters

[in] Type

An X509ProviderType enumeration value that defines the provider type.

  • If you specify XCN_PROV_NONE and set the pAlgorithm parameter to a value other than NULL, the default Cryptography API: Next Generation (CNG) provider is used.
  • If you specify a value other than XCN_PROV_NONE and set the pAlgorithm parameter to NULL, the default legacy cryptographic service provider (CSP) is used.

[in, optional] pAlgorithm

Pointer to an IObjectId interface that represents an algorithm OID. This parameter is optional and can be NULL. For more information, see the Type parameter.

[in] MachineContext

A VARIANT_BOOL variable that indicates whether to use the computer or user context to determine the default provider for the specified provider type. Specify VARIANT_TRUE for the computer and VARIANT_FALSE for the user.

Return value

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. Possible values include, but are not limited to, those in the following table. For a list of common error codes, see Common HRESULT Values.

Return code/value Description
HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
The object is already initialized.

Remarks

The InitializeFromType method validates the specified type and saves it in the Type property, retrieves the default provider, and sets the following property values on the ICspInformation object:

The method adds the available algorithms to the ICspAlgorithms collection returned by the CspAlgorithms property. Call the InitializeFromName method to initialize the object from a CSP name.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header certenroll.h
DLL CertEnroll.dll

See also

ICspInformation