CertAddCertificateContextToStore

From: Mario (nospam.mario.dambauer_at_nospam.gmx.at)
Date: 04/06/04


Date: Tue, 6 Apr 2004 10:00:22 +0200

When I try to run CertAddCertificateContextToStore I get an error message:

Application Error
The instruction at ".." referenced mem at "..". The mem could net be
written"....

The returned error code of GetLastError is: 2147942405

I don't know whats wrong, I am using this code:

pfxStore = PFXImportCertStore(&blob, password, CRYPT_MACHINE_KEYSET |
CRYPT_EXPORTABLE);
...
myStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL,
CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, L"MY");
...
while (0 != (pctx = CertEnumCertificatesInStore(pfxStore, pctx)))
....
if (!CertAddCertificateContextToStore(myStore, pctx, CERT_STORE_ADD_NEW,
NULL))
{
err = GetLastError();
...

myStore and pctx are valid pointers, but the result is always the same!

Any ideas on fixing this error?
Thanks in advance.

Mario