Visual Basic打开URL与默认浏览器

Noo*_*ath 13 browser vb6 url

编辑

对于VB 6

结束编辑

嘿,这似乎应该是一个简单的修复,我不是特别喜欢Visual Basic语言,但我如何使用代码在默认的Web浏览器中打开一个URL?

编辑
为什么我一直收到此错误?

调用PInvoke函数'CrackleMail!WindowsApplication1.FormFinal :: ShellExecute'使堆栈失去平衡.这很可能是因为托管PInvoke签名与非托管目标签名不匹配.检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配.

kja*_*ack 12

接受的答案中的代码给我一个编译错误我从MSDN获得以下代码使用ShellExecute启动默认的Web浏览器

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 r As Long
   r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
End Sub
Run Code Online (Sandbox Code Playgroud)


aba*_*hev 11

VB.NET:

System.Diagnostics.Process.Start("http://example.com")
Run Code Online (Sandbox Code Playgroud)

VB 6(不确定):

Declare Function ShellExecuteA Lib "shell32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Integer) As IntPtr

ShellExecuteA(Me.Handle, "open", "http://example.com", "", "", 4)
Run Code Online (Sandbox Code Playgroud)

  • 谢谢更改ShellExecute(Me.Handle ...到ShellExecuteA(Me.Handle (2认同)