我需要在隐藏模式下运行IE11 (不显示浏览器),这样我就可以设置cookie了。这是我以前在IE9中使用的代码
cmd = (String)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\IE.AssocFile.HTM\shell\opennew\command", "", null);
url = "http://www.stackoverflow.com";
Process process = Process.Start(new ProcessStartInfo()
{
FileName = cmd,
Arguments = url,
WindowStyle = ProcessWindowStyle.Hidden
});如果我在一台带有IE11的机器上使用它,它会显示浏览器。有办法让我这么做吗?
发布于 2015-01-19 17:45:32
你建议你用另一种方式来设置曲奇:
[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern bool InternetSetCookie(string lpszUrl, string lpszCookieName, string lpszCookieData);您可以在下面的示例中找到使用它的方法:
bool b = InternetSetCookie("http://localhost/", "keyname", "value; Expires = + DateTime.Now.AddDays(10).ToString("R"));https://stackoverflow.com/questions/28030034
复制相似问题