Hi all and thanks for taking the time to read this. I have a c# application where I wish to override the default WinInet cookie settings. The goal is that even when the system WinInet cookie privacy settings are set to Block All, within my process, cookies will still be accepted calls. Reading the documentation, it looked straightforward enough. Here's a cleaned up version of what I have:
private unsafe void SuppressWininetBehavior()
{
int option = (int)WinInet.SuppressBehaviorFlags.INTERNET_SUPPRESS_COOKIE_POLICY;
int* optionPtr = &option;
bool success = WinInet.InternetSetOption(IntPtr.Zero, WinInet.InternetOption.INTERNET_OPTION_SUPPRESS_BEHAVIOR, new IntPtr(optionPtr), sizeof(int));
if (!success)
{
_log.Warn("Failed in WinInet.InternetSetOption call with INTERNET_OPTION_SUPPRESS_BEHAVIOR, INTERNET_SUPPRESS_COOKIE_POLICY");
}
}
Where WinInet.InternetSetOption is defined as:
[DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return : MarshalAs(UnmanagedType.Bool)]
public static extern bool InternetSetOption(IntPtr hInternet, InternetOption dwOption, IntPtr lpBuffer, int dwBufferLength);
And the constants are:
WinInet.InternetOption.INTERNET_OPTION_SUPPRESS_BEHAVIOR = 81
WinInet.SuppressBehaviorFlags.INTERNET_SUPPRESS_COOKIE_POLICY = 1
The InternetSetOption call succeeds - no error.
I have also tried passing in a global internet handle returned by InternetOpen as the first parameter to the InternetSetOption call, and it makes no difference. Cookies continue to be blocked within my process.
The Reason I need to do this is that I have an embedded Flash Player ActiveX instance which makes web requests. I have successfully used other InternetSetOption calls to modify the proxy settings that Flash uses in my process. I'm testing this on Windows 7.