Пропишите using, все не нужны, но данных хватит. Чистить этот список можно бы, но да ладно это не главное в данном посте
using System; using System.ComponentModel; using System.Linq; using System.Net; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Runtime.InteropServices; using System.Text.RegularExpressions;
Пишем всякое вспомогательное
public struct CRYPTUI_WIZ_IMPORT_SRC_INFO { public Int32 dwSize; public Int32 dwSubjectChoice; [MarshalAs(UnmanagedType.LPWStr)] public String pwszFileName; public Int32 dwFlags; [MarshalAs(UnmanagedType.LPWStr)] public String pwszPassword; } [DllImport("CryptUI.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern Boolean CryptUIWizImport( Int32 dwFlags, IntPtr hwndParent, IntPtr pwszWizardTitle, ref CRYPTUI_WIZ_IMPORT_SRC_INFO pImportSrc, IntPtr hDestCertStore ); public const Int32 CRYPTUI_WIZ_IMPORT_SUBJECT_FILE = 1; public const Int32 CRYPT_EXPORTABLE = 0x00000001; public const Int32 CRYPT_USER_PROTECTED = 0x00000002; public const Int32 CRYPTUI_WIZ_NO_UI = 0x0001;
А теперь как это всё использовать
CRYPTUI_WIZ_IMPORT_SRC_INFO importSrc = new CRYPTUI_WIZ_IMPORT_SRC_INFO(); importSrc.dwSize = Marshal.SizeOf(importSrc); importSrc.dwSubjectChoice = CRYPTUI_WIZ_IMPORT_SUBJECT_FILE; importSrc.pwszFileName = "Cert.crl"; importSrc.pwszPassword = null; //bool z = File.Exists("C:\CenterInformMskf (1).crl"); importSrc.dwFlags = CRYPT_EXPORTABLE | CRYPT_USER_PROTECTED; if (!CryptUIWizImport( CRYPTUI_WIZ_NO_UI, IntPtr.Zero, IntPtr.Zero, ref importSrc, IntPtr.Zero )) { MessageBox.Show("Error!"); return; } MessageBox.Show("OK!");
No comments:
Post a Comment
Note: only a member of this blog may post a comment.