CertRegisterPhysicalStore function
The CertRegisterPhysicalStore function adds a physical store to a registry system store collection.
Syntax
BOOL WINAPI CertRegisterPhysicalStore( _In_ const void *pvSystemStore, _In_ DWORD dwFlags, _In_ LPCWSTR pwszStoreName, _In_ PCERT_PHYSICAL_STORE_INFO pStoreInfo, _In_ void *pvReserved );
Parameters
- pvSystemStore [in]
-
The system store collection to which the physical store is added. This parameter points either to a null-terminated Unicode string or to a CERT_SYSTEM_STORE_RELOCATE_PARA structure. For information about using the structure and on adding a ServiceName or ComputerName before the system store name string, see CertRegisterSystemStore.
- dwFlags [in]
-
The high word of the dwFlags parameter specifies the location of the system store. For information about defined high-word flags and appending ServiceName, UserNames, and ComputerNames to the end of the system store name, see CertRegisterSystemStore.
The following low-word flags are also defined and can be combined with high-word flags using a bitwise-OR operation.
Value Meaning - CERT_SYSTEM_STORE_RELOCATE_FLAG
The system store is not in its default registry location and the pvSystemStore parameter must be a pointer to a CERT_SYSTEM_STORE_RELOCATE_PARA structure.
- CERT_STORE_CREATE_NEW_FLAG
The function fails if the physical store already exists in the store location.
- pwszStoreName [in]
-
A pointer to a Unicode string that names the physical store to be added to the system store collection. To remove a physical store from the system store collection, call the CertUnregisterPhysicalStore function.
- pStoreInfo [in]
-
A pointer to a CERT_PHYSICAL_STORE_INFO structure that provides basic information about the physical store.
- pvReserved [in]
-
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.
Examples
The following example shows adding a physical store to a registry system store collection. For an example that includes the complete context for this example, see Example C Program: Registering Physical and System Certificate 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; CERT_PHYSICAL_STORE_INFO PhysicalStoreInfo; // Initialize PhysicalStoreInfo. PhysicalStoreInfo.cbSize = sizeof(CERT_PHYSICAL_STORE_INFO); PhysicalStoreInfo.pszOpenStoreProvider = (LPSTR)CERT_STORE_PROV_FILENAME; PhysicalStoreInfo.dwFlags = CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG; // Replace the path below with one that is appropriate for you. PhysicalStoreInfo.OpenParameters.pbData = (BYTE *) L"C:\\temp\\mystore"; PhysicalStoreInfo.OpenParameters.cbData = (wcslen((LPWSTR) PhysicalStoreInfo.OpenParameters.pbData) + 1) * sizeof(WCHAR); PhysicalStoreInfo.dwPriority = 1; PhysicalStoreInfo.dwOpenEncodingType = PKCS_7_ASN_ENCODING | X509_ASN_ENCODING ; // Register the physical store. if(CertRegisterPhysicalStore( L"NEWSTORE", dwFlags, L"TESTOR.STO", &PhysicalStoreInfo, NULL )) { printf("Physical store is registered. \n"); } else { printf("The physical store was not registered.\n"); exit(1); }
Requirements
|
Minimum supported client |
Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Certificate Store Functions
- CERT_PHYSICAL_STORE_INFO
- CertEnumPhysicalStore
- CertEnumSystemStore
- CertEnumSystemStoreLocation
- CertRegisterSystemStore
- CertUnregisterPhysicalStore