IX509ExtensionTemplate::InitializeEncode method (certenroll.h)

The InitializeEncode method initializes the extension from a template object identifier (OID) and from major and minor version numbers. This method is web enabled.

Syntax

HRESULT InitializeEncode(
  [in] IObjectId *pTemplateOid,
  [in] LONG      MajorVersion,
  [in] LONG      MinorVersion
);

Parameters

[in] pTemplateOid

Pointer to an IObjectId interface that represents the template OID.

[in] MajorVersion

A LONG variable that contains the major version number of the template. The default value is zero (0).

[in] MinorVersion

A LONG variable that contains the minor version number of the template. The default value is zero (0).

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

You must call either InitializeEncode or InitializeDecode before you can use an IX509ExtensionTemplate object. The two methods complement each other. The InitializeEncode method enables you to construct a Distinguished Encoding Rules (DER) encoded Abstract Syntax Notation One (ASN.1) extension object from raw data, and the InitializeDecode method enables you to initialize the raw data from an encoded object.

You can retrieve the following properties for this extension:

  • The Critical property identifies whether the extension is critical. You can also specify this property.
  • The ObjectId property retrieves the OID.
  • The MajorVersion and MinorVersion properties retrieve the version information.
  • The TemplateOid property retrieves the OID of the template.

You must call either InitializeEncode or InitializeDecode before you can use an IX509ExtensionBasicConstraints object. The two methods complement each other. The InitializeEncode method enables you to construct an encoded ASN.1 structure from raw data, and the InitializeDecode method enables you to initialize the raw data from an encoded ASN.1 structure. You can retrieve the raw data for the extension by calling the MajorVersion, MinorVersion, and TemplateOid properties.

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

IX509ExtensionTemplate