【问题标题】:How to enable inPrivate mode in the WebBrowser control如何在 WebBrowser 控件中启用 inPrivate 模式
【发布时间】:2011-10-04 06:55:14
【问题描述】:

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

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

但是,我找不到任何可以访问我希望通过控件公开的 InPrivate 模式的属性。

有没有办法将 InPrivate 模式与 WebBrowser 控件一起使用,或者我必须制作自己的浏览器来支持它?

【问题讨论】:

  • 您需要向我们提供有关此组件的更多信息,是哪家公司生产的?
  • 你的意思是WebBrowser
  • 嗨 Smudge202 感谢您的快速回复。是的,我的意思是 WebBrowser
  • 好吧,我在你的答案中搜索了同样的问题,发现没有这样的事情,然后我想出了一个解决方案,为每个 webbrowser 控件使用不同的窗口帐户。

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


【解决方案1】:

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

您可能会陷入自己控制或寻找替代控制的困境。

【讨论】:

    【解决方案2】:

    这里有一些代码可以让你访问 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
    

    【讨论】:

    • 关于 InPrivate 的好信息,但没有回答问题。 OP 需要此用于 Windows 窗体 WebBrowser 控件。
    • "或者我是否必须制作自己的支持此功能的浏览器" 您可以使用此函数的返回创建自己的浏览器。我假设任何想要制作自己的浏览器的人都知道如何做到这一点。
    • 我认为这是一个错误的假设。这可能只是被告知他想制作自己的浏览器的人。
    • 不是假设,而是问题所在——你没有更好的事情可做吗?
    猜你喜欢
    • 2010-12-08
    • 1970-01-01
    • 2010-12-03
    • 2020-09-08
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多