Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

CertDuplicateStore (crypt32)
 
.

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

C# Signature:

[DllImport("crypt32.dll", SetLastError=true)]
static extern TODO CertDuplicateStore(TODO);

VB Signature:

Declare Function CertDuplicateStore Lib "crypt32.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

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);

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions