#include <windows.h>#include <wincrypt.h>#include "win32exception.h"void InstallTrustedPublisherCertificate(LPCTSTR CertificateFilePath){ DWORD dwContentType; PCCERT_CONTEXT pCertContext = NULL; if (!CryptQueryObject( CERT_QUERY_OBJECT_FILE, CertificateFilePath, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &dwContentType, NULL, NULL, NULL, (const void **)&pCertContext)) throw win32exception("CryptQueryObject"); if (dwContentType != CERT_QUERY_CONTENT_CERT) throw exception("Incorrect content type of crypto object."); __try { HCERTSTORE hCertStore = CertOpenStore( CERT_STORE_PROV_SYSTEM, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_CURRENT_USER, _T("TrustedPublisher")); if (hCertStore == NULL) throw win32exception("CertOpenStore"); __try { if (CertAddCertificateContextToStore(hCertStore, pCertContext, CERT_STORE_ADD_NEWER, NULL)) { // Added certificate to TrustedPublisher store. } else { DWORD err = GetLastError(); if (err == CRYPT_E_EXISTS) { // Certificate already exists in TrustedPublisher store. } else throw win32exception("CertAddCertificateContextToStore", err); } } __finally { CertCloseStore (hCertStore, 0); } } __finally { CertFreeCertificateContext(pCertContext); }}
certutil.exe -addstore TrustedPublisher cert.cer
我验证了这个适用于Windows 7 64位部署签字,但没通过WHQL认证的驱动程序-无需提示 Windows XP中 WHQL认证 看来,在XP中,您仍然需要有驱动通过WHQL认证,以避免在安装提示。 在Windows XP预安装的SPC 对于Windows XP CodeGo.net,你需要从微软下载Windows Server 2003管理工具包并解压的certutil.exe和certadm.dll。那么上面将工作在XP以及。 管理员工具包: 需要注意的是提取的msi文件可以通过7-zip的检查,所以你不需要安装它,以获得您所需要的EXE和DLL。 联系客服