CertRegisterSystemStore function (wincrypt.h)

The CertRegisterSystemStore function registers a system store.

Syntax

BOOL CertRegisterSystemStore(
  [in] const void              *pvSystemStore,
  [in] DWORD                   dwFlags,
  [in] PCERT_SYSTEM_STORE_INFO pStoreInfo,
  [in] void                    *pvReserved
);

Parameters

[in] pvSystemStore

Identifies the system store to be registered. If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in the dwFlags parameter, pvSystemStore points to a CERT_SYSTEM_STORE_RELOCATE_PARA structure. Otherwise, it points to a null-terminated Unicode string that names the system store.

With appropriate settings in dwFlags, the identified store can be a system store on a remote local computer. Stores on remote computers can be registered with the computer name as a prefix to the name of the system store. For example, a remote local computer store can be registered with pvSystemStore pointing to the string "\ComputerName\Trust" or "ComputerName\Trust".

Leading "\" backslashes are optional before a ComputerName.

[in] dwFlags

The high word of the dwFlags parameter is used to specify the location of the system store.

The following high-word values are defined.

Value Meaning
CERT_SYSTEM_STORE_CURRENT_SERVICE
pvSystemStore can be a system store name that is prefixed with the ServiceName.
CERT_SYSTEM_STORE_CURRENT_USER
pvSystemStore can be a system store name that is prefixed with the UserName.
CERT_SYSTEM_STORE_LOCAL_MACHINE
pvSystemStore can be a system store that is on a remote computer.
CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
pvSystemStore is a group policy store and can be on a remote computer.
CERT_SYSTEM_STORE_SERVICES
pvSystemStore must be a system store name prefixed with the ServiceName.
CERT_SYSTEM_STORE_USERS
pvSystemStore must be a system store name that is prefixed with the UserName.
 

Stores on remote computers can be registered for CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES, CERT_SYSTEM_STORE_USERS, or CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY.

The following low-word values are also defined and can be combined using a bitwise-OR operation with high-word values.

Value Meaning
CERT_SYSTEM_STORE_RELOCATE_FLAG
The system store is not in its default register location and pvSystemStore must be a pointer to a CERT_SYSTEM_STORE_RELOCATE_PARA structure.
CERT_STORE_CREATE_NEW_FLAG
The function fails if the system store already exists in the store location.

[in] pStoreInfo

Reserved for future use and must be set to NULL.

[in] pvReserved

Reserved for future use and must be set to NULL.

Return value

If the function succeeds, the function returns nonzero.

If the function fails, it returns zero.

Remarks

To unregister a system store that has been registered by this function, call CertUnregisterSystemStore.

Examples

The following example shows adding a system store to a registry system store collection. For an example that includes the complete context for this example, see Example C Program: Listing System and Physical Stores.

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

LPCWSTR pvSystemName= L"NEWSTORE";  // For this setting of 
                                    // dwFlags, the store name may 
                                    // be prefixed with a user name.
DWORD dwFlags= CERT_SYSTEM_STORE_CURRENT_USER;

if(CertRegisterSystemStore(
    pvSystemName,
    dwFlags,
    NULL,
    NULL))
{
  printf("System store %S is registered. \n",pvSystemName);
}
else
{
  printf("The system store did not register. \n");
  exit(1);
}

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also

CertEnumPhysicalStore

CertEnumSystemStore

CertEnumSystemStoreLocation

CertRegisterPhysicalStore

CertUnregisterPhysicalStore

CertUnregisterSystemStore

Certificate Store Functions