Si potrebbe fare questo per ogni processo utilizzando la funzione InternetSetOption
Win32:
[DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetOption(int hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
e poi a vostra all'avvio dell'applicazione chiamare la seguente funzione:
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 !>?");
}
}
fonte
2013-08-12 20:20:06
E 'possibile fare questo per thread? – EBAG
Io non la penso così. Dopo tutto non dimenticare che il controllo WebBrowser che stai utilizzando è solo un wrapper sull'oggetto COM nativo che rappresenta Internet Explorer. –
Per quanto riguarda i cookie di condivisione, non penso sia possibile nemmeno su base per-thread. La sessione è condivisa per processo per le istanze di WebBrowser. Ecco una [domanda] simile (http://stackoverflow.com/questions/18055734/net-webbrowser-control-and-dispose/18057266#18057266). – Noseratio