如何使用C#清除https网站中的SSL状态?

解决方案 »

  1.   

    csdn上给出的方法,我没有用过,我用VC。
    using System;
    using System.Runtime.InteropServices;namespace Demo
    {
        public class Ssl
        {
            [DllImport("kernel32.dll")]
            internal static extern IntPtr LoadLibrary(String dllname);        [DllImport("kernel32.dll")]
            internal static extern IntPtr GetProcAddress(IntPtr hModule, String procname);        internal delegate bool SslEmptyCacheHelper(IntPtr targetName, int flags);        /// <summary>
            /// UNICODE版
            /// </summary>
            /// <returns></returns>
            public bool SslEmptyCacheW()
            {
                IntPtr schannel = LoadLibrary("Schannel.dll");
                IntPtr procaddr = GetProcAddress(schannel, "SslEmptyCacheW");
                SslEmptyCacheHelper helper = (SslEmptyCacheHelper)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SslEmptyCacheHelper));
                return helper(IntPtr.Zero, 0);
            }        /// <summary>
            /// ANSI版
            /// </summary>
            /// <returns></returns>
            public bool SslEmptyCacheA()
            {
                IntPtr schannel = LoadLibrary("Schannel.dll");
                IntPtr procaddr = GetProcAddress(schannel, "SslEmptyCacheA");
                SslEmptyCacheHelper helper = (SslEmptyCacheHelper)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SslEmptyCacheHelper));
                return helper(IntPtr.Zero, 0);
            }
        }}