VC deletes ie cache, cookies, and records

Source: Internet
Author: User

After using a computer, you often do not want others to discover what you have done or what Web sites you have browsed. (Especially when sharing one machine with multiple people ). Of course, you can manually clear those records. But that's a complicated task. I don't think anyone is willing to do that. So I want to use a software to complete the above work at one time.

There are many articles to clear historical records, but they are generally not comprehensive enough. I have sorted out and collected some information for integration. A comprehensive method for clearing historical records is provided.

Here, we want to point out that the code can be completed. Thank you very much, xzhang.

The figure on the left shows the running of the example program in this article. We can see the specific cleanup content of this example.

Download source code size: 17 KB

The following code shows how to implement it.

First, add: # include "atlbase. H" to stdafx. h"
Set-> link to import to the database: wininet. Lib shlwapi. Lib

// Add the following content to the header file of the dialog box:

# Include "wininet. H" # include "urlhist. H" # define sweep_buffer_size 10000 public: Enum del_cache_type // type of the type to be deleted. {File, // indicates the Internet temporary file cookie // indicates the cookie };
// The following are some auxiliary functions (for more information about how to implement the auxiliary functions, see the source code. This is not provided for the length)
Bool deleteurlcache (del_cache_type); bool emptydirectory (lpctstr szpath, bool bdeletedesktopini = false, bool bwipeindexdat = false); // clear a directory bool iswindowsnt (); // determine the system bool iswindows2k (); bool getusersid (psid * ppsid); void getsidstring (psid, lptstr szbuffer); bool
Getoldsd (hkey, lpctstr pszsubkey, byte ** PSD); bool createnewsd (psid, callback * PSD, PACl * ppdacl); bool Merge (hkey, lpctstr pszsubkey, security_descriptor * PSD, bool brecursive); bool wipefile (lpctstr szdir, lpctstr szfile );

// Now we can clear each item separately.

1. Clear temporary ie files

Tchar szpath [max_path];
Deleteurlcache (File );
If (shgetspecialfolderpath (null, szpath, csidl_internet_cache, false ))
{// Get the temporary directory and clear it.
Emptydirectory (szpath );
}

Another way to clear temporary ie files is to directly call the wininet function. See the following function for clearing temporary ie files.

Bool deltempfiles () {bool bresult = false; bool bdone = false; lpinternet_cache_entry_info lpcacheentry = NULL; DWORD dwtrysize, dwentrysize = 4096; // start buffer size handle hcachedir = NULL; DWORD dwerror = error_insufficient_buffer; do {Switch (dwerror)
{// Need a bigger buffer case when: Delete [] maid; maid = (bytes) New char [dwentrysize]; maid-> dwstructsize = dwentrysize; dwtrysize = dwentrysize; bool bsuccess; if (hcachedir = NULL) bsuccess
= (Hcachedir = findfirsturlcacheentry (null, lpcacheentry, & dwtrysize ))! = NULL; else bsuccess = equals (hcachedir, lpcacheentry, & dwtrysize); If (bsuccess) dwerror = error_success; else {dwerror = getlasterror (); dwentrysize = dwtrysize ;//
Use new size returned} break; // We are done case error_no_more_items: bdone = true; bresult = true; break; // we have got an entry case error_success: // Don ''''''''''''''' doesn't delete cookie entry if (! (Lpcacheentry-> cacheentrytype & cookie_cache_entry) deleteurlcacheentry (lpcacheentry-> lpszsourceurlname );
// Get ready for next entry dwtrysize = dwentrysize; If (values (hcachedir, lpcacheentry, & dwtrysize) dwerror = error_success; else {dwerror = getlasterror (); dwentrysize = dwtrysize; // use new size returned} break; // unknown error default:
Bdone = true; break;} If (bdone) {Delete [] lpcacheentry; If (hcachedir) findcloseurlcache (hcachedir);} while (! Bdone); Return bresult ;}

2. Clear cookies

Tchar szpath [max_path]; deleteurlcache (cookie); If (shgetspecialfolderpath (null, szpath, csidl_cookies, false) {// get the Directory and clear emptydirectory (szpath );}

3. Clear the historical address in the browser address bar

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Internet Explorer \ typedurls "));

4. Clear the Automatic completion history of the form

Cstring skey; DWORD dwret; If (iswindows2k () | iswindowsnt () // first judge the system {cstring sbasekey; security_descriptor newsd; byte * poldsd; PACl pdacl = NULL; psid = NULL; tchar szsid [256]; If (getusersid (& psid) {// get The Hiden key namegetsidstring (psid, szsid ); skey = _ T ("Software \ Microsoft \ protected
Storage System provider \ "); skey + = szsid; // get old sdsbasekey = skey; getoldsd (HKEY_CURRENT_USER, sbasekey, & poldsd ); // set new SD and then clearif (createnewsd (psid, & newsd, & pdacl) {regsetprivilege (HKEY_CURRENT_USER, skey, & newsd, false ); skey + = _ T ("\ data"); regsetprivilege (HKEY_CURRENT_USER,
Skey, & newsd, false); skey + = _ T ("\ e161255a-37c3-11d2-bcaa-00c04fd929db"); regsetprivilege (HKEY_CURRENT_USER, skey, & newsd, true); dwret = shdeletekey (HKEY_CURRENT_USER, skey);} If (pdacl! = NULL) heapfree (getprocessheap (), 0, pdacl); // restore old SDIF (poldsd) {regsetprivilege (HKEY_CURRENT_USER,
Sbasekey, (security_descriptor *) poldsd, false); Delete poldsd;} If (psid) heapfree (getprocessheap (), 0, psid);} // win9xdword dwsize = max_path; tchar szusername [max_path]; GetUserName (szusername, & dwsize); skey = _ T ("Software \ Microsoft \ Protected Storage System
Provider \ "); skey + = szusername; skey + = _ T (" \ data \ e161255a-37c3-11d2-bcaa-00c04fd929db "); dwret = shdeletekey (HKEY_LOCAL_MACHINE, skey );

5. Clear automatic password history

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Internet Explorer \ intelliforms "));

6. Clear content from favorites
Tchar szpath [max_path];
If (shgetspecialfolderpath (null, szpath, csidl_favorites, false ))
{// Get the Directory and clear it
Emptydirectory (szpath );
}

7. Clear the RAS automatic dialing history

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Ras autodial \ addresses "));

8. Clear temporary system folders

Tchar szpath [max_path]; If (gettemppath (max_path, szpath) // obtain the temporary system directory {emptydirectory (szpath, true );}

9. Clear the recycle bin

Shemptyrecyclebin (null, null,
Sherb_noconfirmation | sherb_noprogressui | sherb_nosound );

10. Clear automatic match history in "running"

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ runmru "));

11. Clear historical records in the document

Tchar szpath [max_path]; If (shgetspecialfolderpath (null, szpath, csidl_recent, false) {emptydirectory (szpath);} shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ recentdocs "));

12. Clear last login user records

Shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows NT \ CurrentVersion \ WinLogon"), _ T ("DefaultUserName"); shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows NT \ CurrentVersion \ WinLogon"), _ T ("altdefauserusername"); shdeletevalue (HKEY_LOCAL_MACHINE,
_ T ("Software \ Microsoft \ Windows \ CurrentVersion \ WinLogon"), _ T ("DefaultUserName "));

13. Clear "Search for files" to automatically match historical records

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ doc find spec MRU"); shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Internet Explorer \ Explorer bars \ {C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1} \ containingtextmru"); shdeletekey (HKEY_CURRENT_USER,
_ T ("Software \ Microsoft \ Internet Explorer \ Explorer bars \ {C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1} \ filesnamedmru "));

14. Clear "Search for computer" and automatically match historical records

Shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ findcomputermru"); shdeletekey (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Internet Explorer \ Explorer bars \ {C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1} \ computernamemru "));

15. Clear network connection history

Tchar szpath [max_path]; If (shgetspecialfolderpath (null, szpath, csidl_nethood, false) {// get the Directory and clear emptydirectory (szpath );}

16. Clear remote logon history

Cstring skey; For (INT I = 1; I <= 8; I ++) {skey. format (_ T ("machine % d"), I); shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Telnet"), skey); skey. format (_ T ("service % d"), I); shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Telnet"), skey); skey. format (_ T ("termtype % d "),
I); shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Telnet"), skey);} shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Telnet"), _ T ("lastmachine"); shdeletevalue (HKEY_CURRENT_USER, _ T ("Software \ Microsoft \ Telnet"), _ T ("lastservice"); shdeletevalue (HKEY_CURRENT_USER,
_ T ("Software \ Microsoft \ Telnet"), _ T ("lasttermtype "));

17. Clear browsing URL history
The following function can be used to clear the URL history.

# Include "shlguid. H "hresult clearhistory () {hresult hr; coinitialize (null); {iurlhistorystg2 * purlhistorystg2 = NULL; HR = cocreateinstance (clsid_curlhistory, null, 1, empty, (void **) & purlhistorystg2); If (succeeded (HR) {hR = purlhistorystg2-> clearhistory ();
Purlhistorystg2-> release () ;}} couninitialize (); Return hr ;}

// If the above Code cannot be cleared
// There are the following, not perfect, but can work.

Tchar szpath [max_path]; getwindowsdirectory (szpath, max_path); _ tcscat (szpath, _ T ("\ history"); emptydirectory (szpath, false, true ); if (shgetspecialfolderpath (null, szpath, csidl_history, false) {emptydirectory (szpath, false, true );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.