示例#1
0
        /// <summary>
        ///  The CryptUIDlgViewContext function displays a certificate, CTL, or CRL context.
        /// </summary>
        /// <param name="file">The absolute path to certificate, crl or ctl</param>
        /// <param name="type">one of the values to <code>ObjectType</code></param>
        /// <param name="certStoreContent">one of the values to <code>CertStoreContent</code></param>
        /// <param name="contentFlag">one of the values to <code>CertStoreContentFlag</code></param>
        /// <param name="formatFlag">one of the values to <code>CertQueryFormatFlag</code></param>
        /// <param name="hwdParent">Handle of the window for the display.Required if you want the window to be modal</param>
        /// <param name="title">title of the window</param>
        public static void CryptUIViewContext(String file, ObjectType type, CertStoreContent certStoreContent,
                                              CertStoreContentFlag contentFlag, CertQueryFormatFlag formatFlag,
                                              String title, IntPtr hwdParent)
        {
            IntPtr pvContext = IntPtr.Zero;
            int    contentType;
            bool   bResult = CryptQueryObject(
                (int)type,
                file,
                (int)contentFlag,
                (int)formatFlag,
                0, //reserved for future use
                IntPtr.Zero, out contentType,

                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                ref pvContext
                );

            if (!bResult)
            {
                throw new Exception("CryptQueryObject error #" + Marshal.GetLastWin32Error());
            }
            try
            {
                CryptUIDlgViewContext((contentFlag == CertStoreContentFlag.FlagAll ? contentType : (int)certStoreContent), pvContext, hwdParent, title, 0, IntPtr.Zero);
            }
            finally
            {
                switch (contentFlag)
                {
                case CertStoreContentFlag.Certificate:
                    CertFreeCertificateContext(pvContext);
                    break;

                case CertStoreContentFlag.Crl:
                    CertFreeCRLContext(pvContext);
                    break;
                    //TODO: free up ctl
                }
            }
        }
示例#2
0
        /// <summary>
        ///  The CryptUIDlgViewContext function displays a certificate, CTL, or CRL context.
        /// </summary>
        /// <param name="file">The absolute path to certificate, crl or ctl</param>
        /// <param name="type">one of the values to <code>ObjectType</code></param>
        /// <param name="certStoreContent">one of the values to <code>CertStoreContent</code></param>
        /// <param name="contentFlag">one of the values to <code>CertStoreContentFlag</code></param>
        /// <param name="formatFlag">one of the values to <code>CertQueryFormatFlag</code></param>
        /// <param name="hwdParent">Handle of the window for the display.Required if you want the window to be modal</param>
        /// <param name="title">title of the window</param>
        public static void CryptUIViewContext(String file, ObjectType type, CertStoreContent certStoreContent,
                                              CertStoreContentFlag contentFlag, CertQueryFormatFlag formatFlag,
                                              String title, IntPtr hwdParent)
        {
            IntPtr pvContext = IntPtr.Zero;
            int contentType;
            bool bResult = CryptQueryObject(
                (int) type,
                file,
                (int) contentFlag,
                (int) formatFlag,
                0, //reserved for future use
                IntPtr.Zero,out contentType,

                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                ref pvContext
                );
            if (!bResult)
            {
                throw new Exception("CryptQueryObject error #" + Marshal.GetLastWin32Error());
            }
            try
            {
                CryptUIDlgViewContext((contentFlag == CertStoreContentFlag.FlagAll ? contentType : (int)certStoreContent), pvContext, hwdParent, title, 0, IntPtr.Zero);
            }
            finally
            {
                switch (contentFlag)
                {
                    case CertStoreContentFlag.Certificate:
                        CertFreeCertificateContext(pvContext);
                        break;
                    case CertStoreContentFlag.Crl:
                        CertFreeCRLContext(pvContext);
                        break;
                        //TODO: free up ctl
                }
            }
        }