如何在WebBrowser控件中启用inPrivate模式

时间:2011-07-13 08:04:51

标签: c# winforms web-applications webbrowser-control

我必须制作一个带有一些额外功能的IE浏览器。

在Visual Studio中,我们有一个名为“WebBrowser”的组件,它使用安装在用户个人电脑上的当前IE浏览器。

但是,我无法找到任何能够访问我希望通过控件公开的InPrivate模式的属性。

有没有办法在WebProwser控件中使用InPrivate模式,还是我必须创建自己的浏览器来支持这个?

2 个答案:

答案 0 :(得分:2)

根据EricLaw's answers上的related question,听起来这可能是不可能的。

您可能会被困在自己控制或寻找替代控制之中。

答案 1 :(得分:0)

这里有一些代码可以让您访问InPrivate IE

Friend Function Open(Optional ByVal Url As String = "about:blank", Optional ByVal WindowState As ProcessWindowStyle = ProcessWindowStyle.Hidden) As WebBrowser
On Error Resume Next

Dim Start As New ProcessStartInfo
Dim Windows = New ShellWindowsClass
Dim Count = Windows.Count
Start.FileName = "iexplore.exe"
Start.Arguments = "-private -nomerge " & Url
If WindowState = ProcessWindowStyle.Hidden Then
  Start.WindowStyle = ProcessWindowStyle.Minimized
Else
  Start.WindowStyle = WindowState
End If
Process.Start(Start)

'Wait is my own class that waits for 10 secs
Wait.Reset()
Do
  If Windows.Count > Count Then Exit Do
Loop While Wait.Waiting

Browser = Windows(Count)
Browser.Visible = (WindowState <> ProcessWindowStyle.Hidden)
Return Browser
End Function
相关问题