自助推荐
立即入驻

VB利用API函数调用默认浏览器打开网址

博客3年前更新 桔子雨
1,154 00

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_SHOWNORMAL = 1

函数返回值为大于32的整数表明成功执行调用,小于或等于32表明调用失败。
例如:

Dim Result
Result = ShellExecute(0, vbNullString, "http://www.ccw.com.cn", vbNullString, vbNullString, SW_SHOWNORMAL)
If Result <= 32 Then
MsgBox "调用浏览器失败!", vbOKOnly + vbCritical, "错误:", 0
End If
© 版权声明

相关文章