How to enable inPrivate mode in the WebBrowser control

时光总嘲笑我的痴心妄想 提交于 2019-11-28 02:59:50

问题


I have to make a IE type browser with some extra features on it.

In Visual Studio, we have a component named "WebBrowser" that uses current IE browser installed in user's pc.

However, I am unable to find any property that enables access to the InPrivate mode I hoped would be exposed by control.

Is there a way to use InPrivate mode with the WebBrowser control, or would I have to make my own browser that supports this?


回答1:


According to EricLaw's answers on a related question, it sounds like this might not be possible.

You might be stuck making your own control or looking for an alternative one.




回答2:


Here's some code that will give you access to an 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


来源:https://stackoverflow.com/questions/6675864/how-to-enable-inprivate-mode-in-the-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!