Clear browse traces with VC

zhaozj2021-02-11  235

Clear browsing traces with VC [Author: Don Chan, Yu Zhicheng Add Time: 2001-5-26 12:10:21]

Browse, always leave some traces. Handmade one by one, I really annoy. So let us use the program to clear the browsing traces once again.

1. Clear files in the specified directory

As we all know, most "garbage" is placed under the designated folder, you only need to delete these files.

This can be made by the deletefile function in the Windows API. We can make it a relatively complete function to delete the selected type file under the specified folder. The function expansion code is as follows:

Void DelmyPointFile (LPSTR NAME, LPSTR CURRENTPATH) {// Remove the specified file under the specified path, support wildcard // name: Deleted files; CurrentPath: Found file path WIN32_FIND_DATA FILEDATA; Handle HSearch; char szhome [max_path]; / / char szFile [MAX_PATH]; DWORD RightWrong; // HDC MyDiaDC; DWORD NameLength; // current program path RightWrong = GetCurrentDirectory (MAX_PATH, szHome); RightWrong = SetCurrentDirectory (currentPath); // save the program execution path, then, the the current path to the path setting need to find hSearch = FindFirstFile (name, && FileData); if (hSearch = INVALID_HANDLE_VALUE!) {NameLength = lstrlen (FileData.cFileName); DeleteFile (FileData.cFileName); while (FindNextFile (hSearch, && FileData) ) {// find a file, find a delete a namegrandth = lstrlen (FileData.cfileName);} findclose (hsearch); // Close Find handle} RightWrong = setCurrentDirectory (szhome);}

With this function, you can clear the document menu, system temporary directory, and IE temporary directory with the following code.

Char windowRecentPath [] = "// Recent"; char windowTemp [] = "// Temp"; char windowietemp [] = "// Temporary Internet files"; char windowcookie [] = "// cookies"; char szwindowspath [max_path ]; char szDelPath [MAX_PATH]; ... GetWindowsDirectory (szWindowsPath, MAX_PATH); lstrcpy (szDelPath, szWindowsPath); lstrcat (szDelPath, WindowRecentPath); // delete the file window list of recently used DelMyPointFile ( ". * *", szDelPath ); lstrcpy (szDelPath, szWindowsPath); lstrcat (szDelPath, WindowTemp); // delete temporary files window DelMyPointFile ( "* *.", szDelPath); lstrcpy (szDelPath, szWindowsPath); lstrcat (szDelPath, WindowIETemp); // delete Window IE Temporary Document DelmyPointFile ("*. *", szdelpath); 2. Clear of "History"

IE "History" has always been a headache, even if you set "history" to zero, you can save the content of the day; try to delete the file, but because the file is in load mode, this road is not passing; The API that can also be found is also found. Fortunately, IE's clear function can be made. IE is a typical COM component, we can directly clear "history" by calling its component modules.

HRESULT ClearHistory () {// build IUrlHistoryStg2 assembly pointer IUrlHistoryStg2 * pUrlHistoryStg2 = NULL; // initialize the COM library CoInitialize (NULL); // build client object HRESULT hr = CoCreateInstance (CLSID_CUrlHistory, NULL, CLSCTX_INPROC, IID_IUrlHistoryStg2, (void) && pUrlHistoryStg2 ); if (succeededed (hr)) {// interface call hr = purlhistorystg2-> clelhistorystory (); purlhistorystg2-> release ();} // closes the COUNInInInInIze (); Return HR;}

3. Clear the drop-down cache list

The drop-down cache list of IE keeps your browsed URL, but the above code cannot clear it. The three functions of FindNextURLCachentry, DeleteURLCachentry, and FindFirsturlcachentry, DELETEURLCACHEENTRYEENTRY are available in Windows APIs. And there is a more lazy way in Window 9x, that is, directly delete the registry. code show as below:

void DelRegCache () {// delete the records stored in the registry IE cache LPCSTR RootKey = "HKEY_CURRENT_USER"; LPCSTR SubKey = "Software // Microsoft // Internet Explorer // TypedURLs"; RegDeleteKey (HKEY_CURRENT_USER, SubKey);} Cookie deletes cookies Save in the cookies subdirectory of the system directory, if you do not open IE, you can delete it directly. If you open IE, since it saves a part in memory, you can use the code to delete. InternetSetOption (0, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0); lstrcpy (szDelPath, szWindowsPath); lstrcat (szDelPath, WindowCookie); // delete window IE temporary files DelMyPointFile ( "* *.", SzDelPath); The above code in VC 6.0, Windows Upper 98, can meet most of the usage needs. However, in the above code, the DelmyPointFile feature is more single, and can only delete the files in the directory, and it is powerful for the subdirectory. Interested readers can write a recursive process to improve its function.

related information:

-

Enumerate NT SERVICES

-

Personalism: writing program methods

-

ODBC programming instance in Visual C

-

Using serial communication controls in VC 6.0

-

Profile using VC 6.0 production ASP Server Control

转载请注明原文地址:https://www.9cbs.com/read-3893.html

New Post(0)