vb 如何调用默认浏览器 10
4个回答
展开全部
默认浏览器不是IE浏览器,VB可以打开自行设置的默认浏览器来浏览网页。
可以用以下两种代码方式打开。
代码1)用Shell函数直接调用explorer.exe来打开网页。
Private Sub Command1_Click() Dim strOpen strOpen = Shell("explorer.exe "
& Text1, 1)End SubPrivate Sub Form_Load() Text1 =
"http://zhidao.baidu.com"End Sub
代码2)使用Api函数ShellExecute实现打开网页。
Option Explicit 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 Dim strUrl As String Private Sub OpenUrl(tUrl As
String) ShellExecute Me.hwnd, "Open", tUrl, 0, 0, 0End SubPrivate Sub
Command1_Click() strUrl = Text1.Text OpenUrl (strUrl)End SubPrivate Sub
Form_Load() Text1 = "http://zhidao.baidu.com/"End Sub
两种方式都能在设置谷歌浏览器为默认浏览器状况下,打开想看的网页。
可以用以下两种代码方式打开。
代码1)用Shell函数直接调用explorer.exe来打开网页。
Private Sub Command1_Click() Dim strOpen strOpen = Shell("explorer.exe "
& Text1, 1)End SubPrivate Sub Form_Load() Text1 =
"http://zhidao.baidu.com"End Sub
代码2)使用Api函数ShellExecute实现打开网页。
Option Explicit 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 Dim strUrl As String Private Sub OpenUrl(tUrl As
String) ShellExecute Me.hwnd, "Open", tUrl, 0, 0, 0End SubPrivate Sub
Command1_Click() strUrl = Text1.Text OpenUrl (strUrl)End SubPrivate Sub
Form_Load() Text1 = "http://zhidao.baidu.com/"End Sub
两种方式都能在设置谷歌浏览器为默认浏览器状况下,打开想看的网页。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
shell"http//www.baidu.com/"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hWnd, vbNullString, "www.baidu.com ", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hWnd, vbNullString, "www.baidu.com ", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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 Sub Command1_Click()
Dim Result
Result = ShellExecute(0, vbNullString, "http://www.baidu.com/", vbNullString, vbNullString, SW_SHOWNORMAL)
If Result <= 32 Then
MsgBox "调用浏览器错误!", vbOKOnly + vbCritical, "错误:", 0
End If
End Sub
Private Sub Command1_Click()
Dim Result
Result = ShellExecute(0, vbNullString, "http://www.baidu.com/", vbNullString, vbNullString, SW_SHOWNORMAL)
If Result <= 32 Then
MsgBox "调用浏览器错误!", vbOKOnly + vbCritical, "错误:", 0
End If
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |