|
VB用IE浏览器打开网页源码,及用其它指定的浏览器打开网页源码。
先在窗体模块里申明API函数
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
然后在窗体上建一个按钮,建立以下代码,以下代码是用于用默认的浏览器打开某一个网页。
Private Sub Command1_Click()
wz = "http://bbs.aitaoji.cn"
Call ShellExecute(0, "open", wz, "", "", SW_SHOW)
End Sub
如果要指定要某个浏览器来打开某个网址,如强制用IE浏览器打开某个网页,代码如下:
Private Sub Command1_Click()
wz = "http://bbs.aitaoji.cn"
Call ShellExecute(0, "open", "C:\Program Files\Internet Explorer\iexplore.exe", wz, "", SW_SHOW)
End Sub
假定电脑里安装了360浏览器,360浏览器安装的位置在:D:\Users\Administrator\AppData\Roaming\360se6\Application\360se.exe,那么强制用360浏览器打开网页的代码如下:
Private Sub Command1_Click()
wz = "http://bbs.aitaoji.cn"
Call ShellExecute(0, "open", "c:\Users\Administrator\AppData\Roaming\360se6\Application\360se.exe", wz, "", SW_SHOW)
End Sub
|
|