CryptGetOIDFunctionValue

The CryptGetOIDFunctionValue function gets the value for the specified encoding type, function name, OID, and value name.

#include <wincrypt.h>
BOOL WINAPI CryptGetOIDFunctionValue(
  DWORD dwEncodingType,        // in
  LPCSTR pszFuncName,          // in
  LPCSTR pszOID,               // in
  LPCWSTR pwszValueName,       // in
  DWORD *pdwValueType,         // out
  BYTE *pbValueData,           // out
  DWORD *pcbValueData          // in, out
);
 

Parameters

dwEncodingType
The type of encoding specified. Note that either a certificate or message encoding type is required. If the low-order word containing the certificate encoding type is nonzero, then it is used. Otherwise, the high-order word containing the message encoding type is used. If both are specified, the certificate encoding type in the low-order word is used.

Currently defined encoding types are shown in the following table:
Encoding type Value
None 0x00000000
CRYPT_ASN_ENCODING 0x00000001
X509_ASN_ENCODING 0x00000001
PKCS_7_ASN_ENCODING 0x00010000

pszFuncName
The name of the OID function set.
pszOID
If the high-order word of the OID is nonzero, pszOID is a pointer to either an OID string, such as "2.5.29.1" or an ASCII string, such as "file". If the high-order word of the OID is zero, the low-order word specifies the numeric identifier to be used as the object identifier.
pwszValueName
Points to a null-terminated UNICODE string containing the name of the value to be queried.
pdwValueType
Points to a variable that receives the value's type. The type returned through this parameter will be one of the following:
Value Meaning
REG_DWORD A 32-bit number.
REG_EXPAND_SZ A null-terminated UNICODE string that contains unexpanded references to environment variables (for example, "%PATH%").
REG_MULTI_SZ An array of null-terminated UNICODE strings, terminated by two null characters.
REG_SZ A null-terminated UNICODE string.

The pdwValueType parameter can be NULL if the type is not required.

pbValueData
Points to a buffer that receives the value associated with the pwszValueName parameter. The buffer should be big enough to contain the terminating null character. This parameter can be NULL if the data is not required.

This parameter can be NULL if you want to get the size of the buffer for memory allocation purposes. For more information, see Common In/Out Parameter Conventions.

pcbValueData
Points to a variable that specifies the size, in bytes of the buffer pointed to by the pbValueData.

In all cases the value returned in *pcbValueData always includes the size of the terminating null character in the string.

Note that when processing the data returned in the buffer, applications need to use the actual size of the data returned. The actual size may be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to insure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

Return Values

TRUE if the function succeeded. FALSE if the function failed.

Call GetLastError to see the reason for any failures.

This function has the following error codes.

Error code Description
ERROR_MORE_DATA If the buffer specified by the pbValueData parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code, and stores the required buffer size, in bytes, into the variable pointed to by pcbValueData.

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
  Windows: Requires Windows 98 (or Windows 95 with IE 3.02 or later).
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.