@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Creates a certificate context from an encoded certificate and adds it to the certificate store. !!!!C# Signature: [DllImport("CRYPT32.DLL", EntryPoint = "CertAddEncodedCertificateToStore", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CertAddEncodedCertificateToStore(IntPtr certStore, int certEncodingType, byte[] certEncoded, int certEncodedLength, int addDisposition, IntPtr certContext); !!!!VB Signature: Declare Function CertAddEncodedCertificateToStore Lib "crypt32.dll" (TODO) As TODO !!!!User-Defined Types: None. !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: IntPtr store = CertOpenSystemStore(0, CERT_STORE_NAME); if(store != IntPtr.Zero) { FileStream ifs = new FileStream("MyTest.cer", FileMode.Open, FileAccess.Read); if(ifs != null) { byte[] cert = new byte[ifs.Length]; for(int i = 0; i < ifs.Length; i++){ cert[i] = (byte)ifs.ReadByte(); } if(CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, cert, cert.Length, CERT_STORE_ADD_REPLACE_EXISTING, IntPtr.Zero)) { MessageBox.Show("Certificate added"); } else { MessageBox.Show("Could not add certificate"); } } else { MessageBox.Show("Could not open certificate file"); } CertCloseStore(store, 0); } Documentation: CertAddEncodedCertificateToStore@msdn on MSDN
Edit crypt32.CertAddEn...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.