The CertDuplicateStore function duplicates a store handle by incrementing the store's reference count.
[DllImport("crypt32.dll", SetLastError=true)]
static extern TODO CertDuplicateStore(TODO);
Declare Function CertDuplicateStore Lib "crypt32.dll" (TODO) As TODO
None.
Do you know one? Please contribute it!
None.
Please add some!
The following example shows creating an alias for a store handle and incrementing the store's reference count.
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);