How to register Physical store for all users at once?



Hello,



I would like to add my own certificate store to a registry system store collection so that all local users can access my own store provider through cert manager apps such as “internet option” on control panel.

It works well once after the following code is run.

However I need to run this code with all local user accounts. Also it is needed to unregister the added store with all local user accounts when uninstall.

Since I need to make it available by the installer, I am looking for any better way to register physical store by one operation.



Any helps greatly appreciated.

Thanks and regards,

Masa Doi



//--------------------------------------------------------------------

#define TARGET_STORE_LOCATION CERT_SYSTEM_STORE_CURRENT_USER

#define              SYSTEM_STORE_NAME                 L"My"

#define MY_PHYSICAL_STORE_OPEN_FLAG CERT_SYSTEM_STORE_USERS



#define MY_OID_NAME "myCertStore"

#define MY_OID_FRIENDLY_NAME L"myCert"

#define MY_OID_DLL_NAME L"myCert.dll"

#define MY_OID_FUNC_NAME "myProvOpenStore"



LPCWSTR pvSystemName = SYSTEM_STORE_NAME;

DWORD dwFlags = TARGET_STORE_LOCATION;

LPCWSTR pvStoreName = MY_OID_FRIENDLY_NAME;

CRYPT_DATA_BLOB m_CryptDataBlob;      // not used

m_CryptDataBlob.pbData = NULL;

m_CryptDataBlob.cbData = 0;

CERT_PHYSICAL_STORE_INFO PhysicalStoreInfo;



// Initialize PhysicalStoreInfo.

PhysicalStoreInfo.cbSize = sizeof(CERT_PHYSICAL_STORE_INFO);

PhysicalStoreInfo.pszOpenStoreProvider = MY_OID_NAME;

PhysicalStoreInfo.dwOpenEncodingType = 0;

PhysicalStoreInfo.dwOpenFlags = MY_PHYSICAL_STORE_OPEN_FLAG;

PhysicalStoreInfo.OpenParameters = m_CryptDataBlob;

PhysicalStoreInfo.dwFlags = CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG;

PhysicalStoreInfo.dwPriority = 1;



//--------------------------------------------------------------------

// Register the physical store.

if(!CertRegisterPhysicalStore(

                                                       pvSystemName,

                                                       dwFlags,

                                                       pvStoreName,

                                                       &PhysicalStoreInfo,

                                                       NULL

                                                       ))

{

             return E_FAIL;

} else {

             return S_OK;

}

.