EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

CryptUIDlgViewContext function

The CryptUIDlgViewContext function displays a certificate, CTL, or CRL context.

Syntax


BOOL WINAPI CryptUIDlgViewContext(
  _In_  DWORD dwContextType,
  _In_  const void *pvContext,
  _In_  HWND hwnd,
  _In_  LPCWSTR pwszTitle,
  _In_  DWORD dwFlags,
  _In_  void *pvReserved
);

Parameters

dwContextType [in]

DWORD indicating whether pvContext is a pointer to a certificate, a CRL, or a CTL context as indicated in the following table.

ValueMeaning
CERT_STORE_CERTIFICATE_CONTEXT

PCCERT_CONTEXT

CERT_STORE_CRL_CONTEXT

PCCRL_CONTEXT

CERT_STORE_CTL_CONTEXT

PCCTL_CONTEXT

 

pvContext [in]

A pointer to a certificate, CRL, or CTL context to be displayed.

hwnd [in]

Handle of the window for the display. If NULL, the display defaults to the desktop window.

pwszTitle [in]

Display title string. If NULL, the default context type is used as the title.

dwFlags [in]

Currently not used and should be set to 0.

pvReserved [in]

Reserved for future use.

Return value

This function returns TRUE on success and FALSE on failure.

Examples

The following example shows displaying a certificate.


//-------------------------------------------------------------------
// Declare and initialize variables.

HCERTSTORE       hCertStore = NULL;        
PCCERT_CONTEXT   pCertContext = NULL;      

//-------------------------------------------------------------------
//   Open a certificate store.

if ( hCertStore = CertOpenSystemStore(
     NULL,
     "MY"))
{
     printf("The MY store has been opened.\n");
}
else
{
     printf("A certificate store was not opened.\n");
     exit(1);
}
//-------------------------------------------------------------------
// Use CertEnumCertificatesInStore to retrieve a certificate 
// from the open store. pCertContext is NULL to retrieve the first
//  certificate in the store.

if (pCertContext = CertEnumCertificatesInStore(
     hCertStore,
     pCertContext))
{
    //---------------------------------------------------------------
    //  A certificate was retrieved, display it. 
    if (!CryptUIDlgViewContext(
           CERT_STORE_CERTIFICATE_CONTEXT,  // Display a certificate.
           pCertContext,                    // Pointer to the 
                                            // certificate.
           NULL,
           NULL,
           0,
           NULL))
        {
            printf("CryptUIDlgViewContext call failed.\n");
            exit(1);
        }
}
else
{
     printf("No certificate available. The store may be empty.\n");
     exit(1);
}

//-------------------------------------------------------------------
// When all processing is completed, clean up.
if(pCertContext)
{
   CertFreeCertificateContext(pCertContext);
}

if(hCertStore)
{
     if (!CertCloseStore(hCertStore,0))
     {
          printf("No certificate available. The store may "
			  "be empty.\n");
          exit(1);
     }       
}

For another example that uses this function, see Example C Program: Listing the Certificates in a Store.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Cryptuiapi.h

Library

Cryptui.lib

DLL

Cryptui.dll

See also

CryptUIDlgSelectCertificateFromStore

 

 

Ajouts de la communauté

AJOUTER
Afficher:
© 2014 Microsoft