在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
如果需要编程实现IE选项中清除SSL状态的功能,可用SslEmptyCache函数,SslEmptyCache函数定义在Schannel.dll中,采用动态链接即可。
代码如下:
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); } } }
参考资料: 2、.NET 2.0 中 GetDelegateForFunctionPointer 函数实现原理浅析 [草稿]
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论