VB and Internet Explorer Browsing History

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

VB and Internet Explorer Browsing History

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.

[DeleteTempInternetFiles.jpg]

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")

[DeleteHistory.jpg]

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.

[OrganiseFavourites.jpg]

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.

[InternetProperties.jpg]

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.

Conclusion

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....



About the Author

Hannes du Preez

Hannes du Preez is a Microsoft MVP for Visual Basic. He is a trainer at a South African-based company. He is the co-founder of hmsmp.co.za, a community for South African developers.

Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds