.NET WebBrowser不与IE或其他进程共享cookie(WebBrowser独立cookie方法)
生活随笔
收集整理的這篇文章主要介紹了
.NET WebBrowser不与IE或其他进程共享cookie(WebBrowser独立cookie方法)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
[DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]public static extern bool InternetSetOption(int hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);然后在程序啟動(dòng)函數(shù)處調(diào)用以下函數(shù):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 !>?");}
}
總結(jié)
以上是生活随笔為你收集整理的.NET WebBrowser不与IE或其他进程共享cookie(WebBrowser独立cookie方法)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 九档J6变速箱没有档了是什么原因?
- 下一篇: 禁用Cookie在web浏览器中读取/写