VB and Internet Explorer Browsing History

by Hannes du Preez

Highlights of this article include: the clearing of all the various History settings (this includes the browsing info, cookies, form data, and so on). It also covers how to change Internet Explorer's font settings, and how to access the Organize favourites dialog box from within your program.

Hello, everyone. Today, I will show you how to play around with Internet Explorer's Properties dialog box. Highlights of this article include: the clearing of all the various History settings (this includes the browsing info, cookies, form data, and so on). You also will cover how to change Internet Explorer's font settings, and how to access the Organize favourites dialog box from within your program.

To get access to the Internet Explorer's Properties, you will use the built-in RunDLL32 utility to launch Internet Explorer's Control Panel Applet, with different arguments.

Basically, the RunDLL32 utility enables you to call functions exported from a 32-bit DLL. In other words, Rundll32 loads the specified DLL using LoadLibrary, obtains the address of the function using the GetProcAddress function, and calls the function with the specified arguments, if any. When the function returns, Rundll32 unloads the DLL and exits.

To use the RunDll32 utility in your program, you need to look at the Process class. This class provides access to local and remote processes and enables you to start and stop local system processes.

A Process object provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the code of the process, including parts currently being executed by another thread.

To start a Process, you can use the Start method from the Process class; you also can include the StartInfo parameter whose members can be used to duplicate the functionality of the Run dialog box of the Windows Start menu. Anything that can be typed into a command line can be started by setting the appropriate values in the StartInfo property. The only StartInfo property that must be set is the FileName property. The FileName property does not have to be an executable file. It can be of any file type for which the extension has been associated with an application that is installed on the system. For example, the FileName property can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc extension if you have associated .doc files with a word processing tool, such as Microsoft Word.

On the command line, you can specify actions to take for certain types of files. For example, you can print documents or edit text files. Specify these actions by using the Verb member of the StartInfo property. For other types of files, you can specify command line arguments when you start the file from the Run dialog box. For example, you can pass a URL as an argument if you specify your browser as the FileName. These arguments can be specified in the StartInfo property's Arguments member.

It's time to get started. Open Visual Basic 2005 or 2008. I have already designed your form's layout, as you can see in Figure 1. Feel free to give all objects proper names:

Figure 1: Form Layout

Opening Content Advisor

The first button is labeled Content Advisor; this button will be used to show the Content Advisor dialog box. All you need to do is double-click it and type the following inside its click event:

'Content Advisor
Process.Start("rundll32.exe", "msrating.dll,RatingSetupUI")

Here, you used the Rundll32 utility to call the RatingsSetupUI method that resides inside msrating.dll. This DLL is responsible for Internet Ratings and Local User Management. The RatingSetupUI method allows you to set levels of restrictions; then, another function inside msrating.dll, named RatingCheckUserAccess, uses these settings to compare against these rating labels and determines whether the user is allowed to view the given content based on the associated rating label.

Simple, isn't it?

Figure 2: Content Advisor

Delete Temporary Internet Files

The next button is labeled Delete Temporary Internet files. Edit its code to the following:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8")

All you did here was start the Rundll32 utility via the Process object, and then call the ClearMyTracksByProcess method from the Internet Properties Control Panel applet. The ClearMyTracksByProcess method, which is undocumented, is responsible for cleaning all Internet rrowsing-related data. In this case, you had to supply 8 as a parameter, to delete all temporary files. You'll be working with ClearMyTracksByProcess to all the other browsing data as well.

The rest, concerning the IE history, are basically precisely the same. You just supply a different parameter to the ClearMyTracksByProcess method.


Figure 3: Deleting Temporary Internet Files

Delete Cookies

For the button labeled Delete Cookies, supply 2 (instead of 8), as shown in the following code snippet:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 2")

Delete History

To delete History, supply 1:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 1")


Figure 4: Deleting History

Delete Form Data

To delete all entered Form data Data, supply 16:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 16")

Delete Passwords

To delete all entered Passwords, supply 32:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 32")

Delete All Browsing Information

To delete all Browsing Information, supply 255:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 255")

Delete All Files Stored By Add Ons as Well

To delete all files stored by add ons, supply 4351:

Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 4351")

Organizing Favourites

That was actually quite easy, wasn't it? Now, look at how you can show the Organize Favourites Dialog box from within your program. Double-click the button labeled Organize IE Favorites, and add the following line:

Process.Start("rundll32.exe", "shdocvw.dll,DoOrganizeFavDlg")

Here, you just called the DoOrganizeFavDlg method from shdocvw.dll. shdocw.dll is a library used by Windows applications to add basic file and networking operations. DoOrganizeFavDlg Displays the standard Windows Internet Explorer Organize Favorites dialog box.


Figure 5: Organizing Favourites

Displaying Internet Explorer Properties

To show the Internet Explorer options, all you need to do is to add the following line:

Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL inetcpl.cpl")

Via the use of the Control_RunDLL method, you show the Internet Explorer dialog box. A previous article I wrote on Control Panel applets, "Running Windows XP Control Panel Applets from Visual Basic.NET 2005," explains this more in detail.


Figure 6: Internet Explorer Properties

Changing Internet Explorer Font Settings

The last thing I'll cover today is how to change some of the Font settings. For example, if you want to change Internet Explorer's Fontsize, you need to change two values within the HKCurrentUser\Software\Microsoft\Internet Explorer\International\Scripts\3 Registry key. The values you need change are named IEFontSize and IEFontSizePrivate.

To do this, Import the Microsoft.Win32 namespace at the top of your file.

Double-click the Font size button and add the following:

Dim regkey As RegistryKey

'00 00 00 00 = smallest
'01 00 00 00 = small
'02 00 00 00 = medium
'03 00 00 00 = large
'04 00 00 00 = largest
Dim val() As Byte = {2, 0, 0, 0}
regkey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet
   Explorer\International\Scripts\3", True)

regkey.SetValue("IEFontSize", val)
regkey.SetValue("IEFontSizePrivate", val)

The size can be any one of five available settings, smallest, small, medium, large, largest.

If I change the declaration of val to the following:

Dim val() As Byte = {0, 0, 0, 0}

It would be the smallest. If I changed it to:

Dim val() As Byte = {4, 0, 0, 0}

It would be at its largest. You have to remember that these font settings do not apply only to the Internet Explorer browser but to all HTML Help files as well.


I hope you have enjoyed playing around with some of the Internet Explorer settings, and I sincerely hope that you have learnt something new and useful. Until next time....

This article was originally published on Tuesday Dec 9th 2008
Mobile Site | Full Site