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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s