Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I`ve been looking for an answer long time ago. So, thats what I have:</p> <p>WiX Code:</p> <pre><code>&lt;CustomAction Id="ImportCer.Props" Property="ImportCer" Value="[INSTALLDIR]ca\root.cer" /&gt; &lt;CustomAction Id="ImportCer" Execute="deferred" FileKey="hsminst.dll" DllEntry="ImportCer" /&gt; &lt;CustomAction Id="ImportPfx.Props" Property="ImportPfx" Value="[INSTALLDIR]ca\super.pfx" /&gt; &lt;CustomAction Id="ImportPfx" Execute="deferred" FileKey="hsminst.dll" DllEntry="ImportPfx" /&gt; </code></pre> <p>C++ Code:</p> <pre><code> extern "C" __declspec(dllexport) UINT __stdcall ImportCer(MSIHANDLE hInstall) { char szPath[MAX_PATH]; GetModuleFileNameA(NULL, szPath, MAX_PATH); char certFilePath[MAX_PATH] = {0}; DWORD certFilePathLen = MAX_PATH; MsiGetProperty ( hInstall, "CustomActionData", certFilePath, &amp;certFilePathLen); wchar_t certFilePathW[MAX_PATH]; MultiByteToWideChar( CP_ACP, 0, certFilePath, -1, certFilePathW, MAX_PATH); PCCERT_CONTEXT pCertCtx = NULL; if (CryptQueryObject ( CERT_QUERY_OBJECT_FILE, certFilePathW, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, (const void **)&amp;pCertCtx) != 0) { HCERTSTORE hCertStore = CertOpenStore ( CERT_STORE_PROV_SYSTEM, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, L"root"); if (hCertStore != NULL) { if (!CertAddCertificateContextToStore ( hCertStore, pCertCtx, CERT_STORE_ADD_ALWAYS, NULL)) { return -2; } if (!CertCloseStore (hCertStore, 0)) { return -3; } } else { return -1; } if (pCertCtx) { CertFreeCertificateContext (pCertCtx); } } return 0; } extern "C" __declspec(dllexport) UINT __stdcall ImportPfx(MSIHANDLE hInstall) { char certFilePath[MAX_PATH] = {0}; DWORD certFilePathLen = MAX_PATH; MsiGetProperty ( hInstall, "CustomActionData", certFilePath, &amp;certFilePathLen); wchar_t certFilePathW[MAX_PATH]; MultiByteToWideChar( CP_ACP, 0, certFilePath, -1, certFilePathW, MAX_PATH); CRYPTUI_WIZ_IMPORT_SRC_INFO importSrc; memset( &amp;importSrc, 0, sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO)); importSrc.dwSize = sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO); importSrc.dwSubjectChoice = CRYPTUI_WIZ_IMPORT_SUBJECT_FILE; importSrc.pwszFileName = certFilePathW; importSrc.pwszPassword = L"111111"; importSrc.dwFlags = CRYPT_EXPORTABLE; HCERTSTORE serviceStore = CertOpenStore( CERT_STORE_PROV_SYSTEM, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_CURRENT_USER, L"my"); if (CryptUIWizImport( CRYPTUI_WIZ_NO_UI , NULL, NULL, &amp;importSrc, serviceStore ) == 0) { return -1; } return 0; } </code></pre> <p>Hope will help u</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload