开发者

How to enable inPrivate mode in the WebBrowser control

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开发者_JAVA技巧 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?


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜