当前位置:首页 » 程序代码 » 正文

VB用IE浏览器打开网页源码,及用其它指定的浏览器打开网页源码。

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://www.hao123.com/?tn=91269223_hao_pg"
    Call ShellExecute(0, "open", wz, "", "", SW_SHOW)
End Sub


如果要指定要某个浏览器来打开某个网址,如强制用IE浏览器打开某个网页,代码如下:
Private Sub Command1_Click()
    wz = "http://www.hao123.com/?tn=91269223_hao_pg"
    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://www.hao123.com/?tn=91269223_hao_pg"
    Call ShellExecute(0, "open", "c:\Users\Administrator\AppData\Roaming\360se6\Application\360se.exe", wz, "", SW_SHOW)
End Sub

打赏 支付宝打赏 微信打赏

来源:济亨网

本文链接:http://wb86.com/post/165.html

    << 上一篇 下一篇 >>

    湘公网安备 43011102000514号 - 湘ICP备08100508号