Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / MFC

Web Sweeper - Leave No Trace

Rate me:
Please Sign up or sign in to vote.
2.33/5 (3 votes)
4 Aug 2006CPOL2 min read 33.8K   506   20   3
Internet History Cleaning App
Sample screenshot

Introduction

This is my first post, ever, so bear with me. This program is the fulfillment of many an hour of lazy work, and was my brother's idea since I have no imagination. When I started, I wanted to develop an application that would clean up the mess that Internet Explorer leaves behind, keeping my computer running smoothly, etc. It can't be any simpler than this, all you have to do is press the "Sweep!" button, and it deletes the current users Temporary Internet Files, clears the history, and even goes into the registry and deletes the "TypedUrls" folder, cleaning up the address bar clutter.

Using the Code

Firstly, I haven't tested this code with Firefox, nor have I tried it on all operating systems, so just go with it and if you try it on an OS other than Windows XP Home or Windows 98 SE, leave me a message and tell me how it worked. To clear the history, I borrowed some code (no copyright notifications), it's simple but does the job great. To use, all you need to do is copy and paste in these includes and then the code:

C++
#include <urlhist.h>
#include <Wininet.h>
#include <shlobj.h>
#include <shlguid.h>
#include <shlwapi.h>
C++
CoInitialize(NULL);

  IUrlHistoryStg2* pUrlHistoryStg2 = NULL; 

  HRESULT hr = CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC,
  
  IID_IUrlHistoryStg2, (void**)&pUrlHistoryStg2);

  if (SUCCEEDED(hr))
  {
       hr = pUrlHistoryStg2->ClearHistory(); 

        if (!(SUCCEEDED(hr)))
            goto cleanup;

      pUrlHistoryStg2->Release();

      done++;
  }

Skipping some of the more gritty details (you can download the source code, you know), I'd like to jump to the hardest function for me to make, maybe since I was too lazy, but going through my registry trying to find one folder is hard stuff. It's the function that deletes the "TypedUrls" folder in "HKEY_USERS\\Software\\Microsoft\\Internet Explorer\\TypedURLs":

C++
sKey.Empty();
         
sKey += szSid; 	//szSid is a unique number identifier, the number 
                 	// is computed with a helper function "GetSidString"

sKey += \\Software\\Microsoft\\Internet Explorer\\TypedURLs;

        RegSetPrivilege(HKEY_USERS, sKey, &NewSD, TRUE);
        SHDeleteKey(HKEY_USERS, sKey); 

Something to be aware of, using my compiler, which is Microsoft Visual Studio 6.0 C++, it generates 2 warnings. There is nothing wrong with the program and it works just fine, but it still comes up with them as "possible loss of data". Just forget about them, unless you can find a way to improve the program, in which case by all means leave me a comment or send me an email.

History

  • 1.0 - Initial release
  • 2.1 - Added functionality, including clearing the "Temporary Internet Files" folder and a Progress Bar to Show the Progress of the Application, and Fixed a bug that didn't clear the history on computers running Windows 98
  • 2.2 - Now clears the 'Temp' folder in the 'Local Settings' Folder, however it doesn't clear all of the files
  • 2.4 - Added progress bar again after problems, improved functionality, works great
  • 2.4b - Added read-only text box to tell how many files were detected, and the files that aren't deleted are protected files or the "index.dat"
  • 2.5 - Finally fixed bug where all the autocomplete forms wouldn't clear
  • 2.6 - Added a timer to tell the user how long the sweep took

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Born in California
Living in California
Been programming C++ for nearly 5 years, thank you dad.

Lately, im been put in charge of a web site. Its easy enough, since i know nothing about em, but hey what can you do. And its just for school and i kept it simple since i know almost nothing about web programming(Thank you dreamweaver!!!!!)


Other interests - When im not screwing around with C++, i like to play video games, and who doesnt like doing that, and, well, i dont know what else.

Comments and Discussions

 
QuestionHow to block the IE generate temporary files? Pin
Xuefei.Wu13-Apr-09 16:57
Xuefei.Wu13-Apr-09 16:57 
Question'Bare' with you? Pin
conixsdh19-Jul-06 3:33
conixsdh19-Jul-06 3:33 
AnswerRe: 'Bare' with you? Pin
Canopener400019-Jul-06 11:35
Canopener400019-Jul-06 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.