Expand Minimize

CertDuplicateStore function

The CertDuplicateStore function duplicates a store handle by incrementing the store's reference count.

Syntax


HCERTSTORE WINAPI CertDuplicateStore(
  _In_  HCERTSTORE hCertStore
);

Parameters

hCertStore [in]

A handle of the certificate store for which the reference count is being incremented.

Return value

Currently, a copy is not made of the handle, and the returned handle is the same as the handle that was input. If NULL is passed in, the called function will raise an access violation exception.

Examples

The following example shows creating an alias for a store handle and incrementing the store's reference count. For an example that includes the complete context for this example, see Example C Program: Certificate Store Operations.


HCERTSTORE  hSystemStore;              // The system store handle.
HCERTSTORE  hDuplicateStore;           // Handle for a store to be 
                                       // created as a duplicate
                                       // of an open store. 

//-------------------------------------------------------------------
// Open a system store using CertOpenStore.

if(hSystemStore = CertOpenStore(
     CERT_STORE_PROV_SYSTEM, // The system store will be a 
                             // virtual store.
     0,                      // Encoding type not needed with this
                             // PROV.
     NULL,                   // Use the default HCRYPTPROV. 
     CERT_SYSTEM_STORE_CURRENT_USER,
                             // Set the system store location in the
                             // registry.
     L"MY"))                 // Could have used other predefined 
                             // system stores
                             // including Trust, CA, or Root.
{
   printf("Opened the MY system store. \n");
}
else
{
   printf( "Could not open the MY system store.\n");
   exit(1);
}
//-------------------------------------------------------------------
// Create a duplicate of the MY store.

if(hDuplicateStore = CertDuplicateStore(hSystemStore))
{
  printf("The MY store is duplicated.\n");
}
else
{
  printf("Duplication of the MY store failed.\n.");
  exit(1);
}
//-------------------------------------------------------------------
//   Clean up by closing the store. 
if(hSystemStore)
    CertCloseStore(
        hSystemStore, 
        CERT_CLOSE_STORE_CHECK_FLAG);
if(hDuplicateStore)
    CertCloseStore(
        hDuplicateStore, 
        CERT_CLOSE_STORE_CHECK_FLAG);


Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wincrypt.h

Library

Crypt32.lib

DLL

Crypt32.dll

See also

Certificate Store Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.