Connect Me to the Web - August 1998 - November 2004

I recently needed to include code in an application to connect to the web. Dan Newsome, newsomed@earthlink.net, distributed via ZD Tips, code that shows how to use a couple APIs to determine the default browser then launch the browser using a supplied URL. I wrote a demo program to test the code. I liked using the demo to connect to my 'favorite' sites so I made the demo into a 'real' application. It becomes the tip-of-the month. I added function OpenURL which uses API ShellExecute as an optional method of displaying the URL on April 10, 2000 - see below. On December 5, 2001 I increased the number of URLs that are saved in the registry from 50 to 200. On April 20, 2002 I added code to save the most recently used URL and to point to it when the application is launched.

November 2004 - Major Rewrite - I made a number of significant changes to the application. The most significant change stores the URLs in an Ini file as well as the registry. First the Ini file is checked then if not found the registry is used. Other changes are described below.

November 12, 2004 - Backup Copy - A backup copy is made of the ini file before it is updated. Last night, for an unknown reason, my ini file was corrupted. It is now backed-up before being updated. File name is similar to: Copy (xxx) of ConnectToWebSite.ini. If you downloaded the source code before this date you may want to download the code posted on this date.

February 11, 2004 - Rewrite to Use a Database - I rewrote the application to use an Access database. I did not like the idea of using an ini file and wanted to store more information including comments. The database can be used on a network. And I included conversion routines to merge ini file and registry entries from prior versions of this application.

ConnectToWebSite Screen

The application's GUI:

      ConnectToWeb
      The default set of URLs.

      Open Browser - Check the Open Browser in New Window to open the URL in a new window otherwise the URL is displayed in an opened browser window.

      Add - Add a new URL.

      Edit - Edit the selected URL. Pressing F2 allows the URL to be edited in the ListView.

      Delete - Click Delete to remove the URL.

      Refresh - Reload the database entries. If the application is being used by more than one system then it is possible to add, edit or delete a URL from one system then use Refresh to display the changed information.

      Connect - Click Connect o launch your browser and link to the selected URL and exit.

      Exit - Click Exit to terminate the application.


      Add or Edit the selected URL
      Comments are memo field entries - they can be very long.

      OK - Accept the entry.

      Cancel - Don't change the entry.

Notes

The application is terminated after the site is launched. Only one instance of the application is launched. An Exit button is added [1999/04/15]. Function OpenURL is now an optional method used to display the URL in an open instance of the browser using API ShellExecute. Sample code from Randy Birch's [http://www.mvps.org/vbnet/] site was added [2000/04/10]. Increase maximum number of registry entries from 50 to 200 [2001/12/05]. Save last URL [2002/04/20]. Add 'App Activate' code, see 'Activating a Previous Instance of an Application' [2002/10/20].

The Demo Program Uses These Modules

Use in your application:

Module - Click for More Info Description Used in the Demo To
modConnectToWebSite.bas Contains routines described in this tip. Add it to your application to use the functions.
Uses APIs FindExecutable and ShellExecute.
modRegistry.bas Read and write to the registry. Add to your application.

Not needed in your application:

modLocationLocationLocation.bas Save and get form information. Save the form's location, and support the Windows menu items.
modSendTextToApp.bas Inner application communications. Prevent more than one instance of the application from running at the same time.
modAddBackSlash.bas Add a backslash to a path if needed. Add a backslash to App.Path. Used with Ini file processing.
modInfoAbout.bas Info and about help. Provide help via the web and 'about' info.
modPath.bas Parse a file name into Path/Name Used by cCopyOfName.cls
cFileExists.cls Check for the existence of a file. From Randy Birch. Build an ini file if it does not exist.
cIniFile.cls Process Ini Files From Klaus H. Probst. Read and write to an ini file. Used in the conversion process.
cCopyOfName.cls Create a Backup Copy Make a backup copy of the ini file.

Download VB Code

Click here to download the VB6 source [82k].

Previous Tip    Tip Index    Next Tip

Home

Updated 2005/03/01