[英]Accessing Internet Explorer using vb.net
I'm trying to create a little executable that when launched opens an IE browser to various websites like news sites all in different tabs. 我正在尝试创建一个小的可执行文件,该可执行文件在启动时会打开IE浏览器,以访问所有网站(如新闻网站)的所有标签。 for example, a tab for wsj, nytimes, etc. How do I access IE with vb.net? 例如,用于wsj,nytimes等的选项卡。如何使用vb.net访问IE? What reference do I need to add? 我需要添加什么参考? I can't find any sample code that I can make work I think it is because I am missing a library in my assembly? 我找不到可以工作的示例代码,因为我的程序集中缺少库?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenURL("www.google.com")
End Sub
Private Sub OpenURL(ByVal URL As String)
System.Diagnostics.Process.Start(URL)
End Sub
'Or '要么
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TheBrowser As Object = CreateObject("InternetExplorer.Application")
TheBrowser.Visible = True
TheBrowser.Navigate("www.google.com")
End Sub
'Or add Reference SHDocVw.dll By Browsing System32 '或通过浏览System32添加参考SHDocVw.dll
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TheBrowser = New SHDocVw.InternetExplorerMedium
TheBrowser.Visible = True
TheBrowser.Navigate(URL:="http://www.google.com")
End Sub
You can't open them in tabs: 您无法在标签中打开它们:
Is your application a console application? 您的应用程序是控制台应用程序吗? You can't create multiple tabs, but you can use a System.Diagnostics.Process
to launch individual instances of Internet Explorer. 您不能创建多个选项卡,但是可以使用System.Diagnostics.Process
启动Internet Explorer的各个实例。 You should be able to simply specify the full address of the website as the Process to run, similar to how you can put " http://www.wsj.com " into a run prompt, which will launch your default browser with the Wall Street Journal's website. 您应该能够简单地将网站的完整地址指定为要运行的流程,类似于将“ http://www.wsj.com ”放入运行提示的方式,这将使用Wall启动默认浏览器。街报的网站。
If you are using WinForms, you could always use a WebBrowser control, but that has limitations for tabs as well. 如果使用的是WinForms,则始终可以使用WebBrowser控件,但这也限制了选项卡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.