.NET WebBrowser不与IE或其他进程共享cookie(WebBrowser独立cookie方法)
2017-05-12 01:49
543 查看
[DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetOption(int hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
然后在程序启动函数处调用以下函数:
private unsafe void SuppressWininetBehavior(){/* SOURCE: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328%28v=vs.85%29.aspx * INTERNET_OPTION_SUPPRESS_BEHAVIOR (81):* A general purpose option that is used to suppress behaviors on a process-wide basis.* The lpBuffer parameter of the function must be a pointer to a DWORD containing the specific behavior to suppress.* This option cannot be queried with InternetQueryOption.** INTERNET_SUPPRESS_COOKIE_PERSIST (3):* Suppresses the persistence of cookies, even if the server has specified them as persistent.* Version: Requires Internet Explorer 8.0 or later.*/int option = (int)3/* INTERNET_SUPPRESS_COOKIE_PERSIST*/;int* optionPtr = &option;bool success = InternetSetOption(0, 81/*INTERNET_OPTION_SUPPRESS_BEHAVIOR*/, new IntPtr(optionPtr), sizeof(int));if (!success){MessageBox.Show("Something went wrong !>?");}}
相关文章推荐
- WebBrowser.Navigate异步运行,使其与其他进程同步的方法
- IE8多帐户登录的问题,不共享Cookie的方法
- ASP.NET 调用打印机控件的方法 IEWebBrowser这个组件
- asp.net 1.1 与 asp.net 2.0 共享验证的解决方法!
- 在vb.net中使用webbrowser控件和mshtml以及流操作体会(vb.net内嵌IE,拆取 Web 页)(原创)
- 动态连接库注入到其他进程中的一种新方法
- 为什么VB.net的Shared(共享)方法在C#中叫Static(静态)?
- 关于ASP.NET中调用Excel组件不能结束进程的解决方法
- C#里将其他共享目录映射为本地盘符的方法
- 为什么VB.net的Shared(共享)方法在C#中叫Static(静态)?
- 跨越进程边界共享内核对象的三种方法
- asp.net中的cookie使用方法
- ASP.NET与ASP之间的COOKIE共享问题
- 将动态连接库注入到其他进程中的一种新方法
- asp.net 操作Cookie 方法
- WinXP SP2 IE不能使用cookie的解决方法
- Asp.Net获取本地计算机和其他计算机的MAC值的方法
- 向其他进程注入代码的三种方法
- 向其他进程注入代码的三种方法
- 向其他进程注入代码的三种方法