65.9K
CodeProject is changing. Read more.
Home

Opening the Internet Browser Programmatically

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Aug 18, 2011

CPOL
viewsIcon

11050

Given below is code for opening the Internet browser programmatically in VB 6 and VB.NET.VB 6Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As...

Given below is code for opening the Internet browser programmatically in VB 6 and VB.NET.

VB 6
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 btnWebsite_Click()
    ShellExecute Me.hwnd, "open", "http://www.codeproject.com/", _
                 vbNullString, vbNullString, vbNormal
End Sub
VB.NET

This will open the URL in the default browser:

System.Diagnostics.Process.Start("http://www.codeproject.com")

This will open the website in Internet Explorer. Here you have the option to change the browser in your code.

System.Diagnostics.Process.Start("iexplore.exe", "http://www.codeproject.com")