Opening default web browser from Windows Application

This post deals with opening default web browser from a .NET Application (esp. a Windows Application).
First, copy the following code and paste it in your class.

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

Then, you can use the function ShellExecute() as follows.

Private Sub Button1_Click()
   Dim objBrowser As Long
   objBrowser = ShellExecute(0, "open", "http://easyvsto.wordpress.com", 0, 0, 1)
End Sub

We can also open the default web browser as:

Process.Start("http://easyvsto.wordpress.com")

I usually create a Form and place a WebBrowser control in it and use it for opening any web pages. I will get back to you with that soon.
Microsoft reference for the topic, Click here

Leave a Comment

Your email address will not be published. Required fields are marked *