Clear browse traces with VC

zhaozj2021-02-17  49

Clear browse traces with VC

(Tang Can, Yu Zhi Cheng Cheng 11:10 on May 25) is browsing, and there will always be some traces. Handmade one by one, I really annoy. So let us use the program to clear the browsing traces once again. 1. Clear the files under the specified directory, and most "garbage" is placed under the specified 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 next file, find a delete a Namelength; DELETEFILE (FileData.cfileName);} findclose (hsearch); // Close the search handle} RightWrong = setCurrentDirectory (szhome);} 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. "History" clear IE "history" has always been a headache, even if you set "history" to zero day, you can save The content of the day; try to delete with files, but this road is not available because the file is in load mode; the API can be used in the MSDN. 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 (succeedededed (hr)) {// interface call hr = purlhistorystg2-> clelhistorystory (); purlhistorystg2-> release ();} // closes the COM library coupling counitialize (); return hr;} 3. Clear drop pull Cache List IE The drop-down cache list whose Cache is saved at any time, 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:

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

New Post(0)