Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

PvkGetCryptProv function

The PvkGetCryptProv function gets a handle to a cryptographic service provider (CSP) based on either a private key file or a key container name.

Note  This function has no associated header file or import library. To call this function, you must create a user-defined header file and use the LoadLibrary and GetProcAddress functions to dynamically link to Mssign32.dll.


  _In_      HWND       hwnd,
  _In_      LPCWSTR    pwszCaption,
  _In_      LPCWSTR    pwszCapiProvider,
  _In_      DWORD      dwProviderType,
  _In_      LPCWSTR    pwszPvkFile,
  _In_      LPCWSTR    pwszKeyContainerName,
  _Out_     DWORD      *pdwKeySpec,
  _Out_opt_ LPWSTR     *ppwszTmpContainer,
  _Out_     HCRYPTPROV *phCryptProv


hwnd [in]

If a password is required to decrypt the private key file, this parameter is a handle to the parent of the password dialog box; otherwise, it is NULL.

pwszCaption [in]

A pointer to a null-terminated string for the dialog box caption.

pwszCapiProvider [in]

A pointer to a null-terminated string for the CSP name.

dwProviderType [in]

A DWORD value that represents the cryptographic provider type. For more information, see Cryptographic Provider Types.

pwszPvkFile [in]

A pointer to a null-terminated string that contains the name of a private key file.

pwszKeyContainerName [in]

A pointer to a null-terminated string for the private key container name.

pdwKeySpec [out]

A pointer to a DWORD value for the type of key of the container returned with phCryptProv and ppwszTmpContainer.

ppwszTmpContainer [out, optional]

The address of a pointer to a null-terminated string for the temporary key container name. The PvkGetCryptProv function provides and initializes the temporary container. When calling PvkGetCryptProv, the address should point to a NULL value.

phCryptProv [out]

A pointer to a handle for the CSP.

Return value

If the method succeeds, it returns S_OK.

If the method fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.


The PvkGetCryptProv function first tries to get the provider handle from the key container name specified by the pwszKeyContainerName parameter. If you pass NULL for the pwszKeyContainerName parameter, PvkGetCryptProv tries to get the provider from the private key file specified in the pwszPvkFile parameter.

When you have finished using the CSP, free the provider handle and temporary key container by calling the PvkFreeCryptProv function.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]