分享
 
 
 

一些常用网络工具历史记录的清理

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

bool ClearIEHistory(void) //清理IE缓存

{

try

{

//页面文件的清理

HANDLE hEntry;

LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;

DWord dwEntrySize = 0;

hEntry = FindFirstUrlCacheEntry(NULL, NULL, &dwEntrySize);

lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];

hEntry = FindFirstUrlCacheEntry(NULL, lpCacheEntry, &dwEntrySize);

if(hEntry)

{

do

{

DeleteUrlCacheEntry(lpCacheEntry-lpszSourceUrlName);

dwEntrySize = 0;

FindNextUrlCacheEntry(hEntry, NULL, &dwEntrySize);

delete [] lpCacheEntry;

lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];

}

while (FindNextUrlCacheEntry(hEntry, lpCacheEntry, &dwEntrySize));

}

// 清浏览网址历史记录

HRESULT hr;

IUrlHistoryStg2* pUrlHistoryStg2 = NULL;

CoInitialize(NULL);

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

if (SUCCEEDED(hr))

{

hr = pUrlHistoryStg2-ClearHistory();

pUrlHistoryStg2-Release();

}

CoUninitialize();

//浏览器地址栏历史地址的清除

SHDeleteKey(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Internet EXPlorer\\TypedURLs"));

return true;

}

catch(...)

{

return false;

}

}

bool ClearQQHistory(void) //清理QQ账户文件夹

{

try

{

LPCTSTR szFullPath, szDirectory;

LPCTSTR szQQRegPath = _TEXT("SOFTWARE\\Tencent\\PlatForm_Type_List\\1\\");

LPCTSTR szTMRegPath = _TEXT("SOFTWARE\\Tencent\\PlatForm_Type_List\\2\\");

LPCTSTR szQQGameRegPath = _TEXT("SOFTWARE\\Tencent\\QQGame\\SYS\\");

LPCTSTR szQQGameCfgFile = _TEXT("config\\Info.ini");

if( FindKey_STR(true, szQQRegPath, _TEXT("TypePath")) )

{

if( ReadKey_STR(true, szQQRegPath, _TEXT("TypePath"), MAX_PATH, szFullPath) )

{

if(lstrlen(szFullPath)=9)

{

szDirectory = new const TCHAR[lstrlen(szFullPath)-6+1]; // \QQ.exe

memset((LPTSTR)szDirectory, TCHAR('\0'), lstrlen(szFullPath)-6+1);

_tcsncpy((LPTSTR)szDirectory, szFullPath, lstrlen(szFullPath)-6);

DeleteAccountFolders(szDirectory, _TEXT("LoginUinList.DAT"));

}

}

}

三层交换技术

交换机与路由器密码恢复

交换机的选购

路由器设置专题

路由故障处理手册

数字化校园网解决方案

if( FindKey_STR(true, szTMRegPath, _TEXT("TypePath")) )

{

if( ReadKey_STR(true, szTMRegPath, _TEXT("TypePath"), MAX_PATH, szFullPath) )

{

if(lstrlen(szFullPath)=16)

{

szDirectory = new const TCHAR[lstrlen(szFullPath)-13+1]; // \TMDlls\TM.exe

memset((LPTSTR)szDirectory, TCHAR('\0'), lstrlen(szFullPath)-13+1);

_tcsncpy((LPTSTR)szDirectory, szFullPath, lstrlen(szFullPath)-13);

DeleteAccountFolders(szDirectory, _TEXT("LoginUinList.DAT"));

}

}

}

if( FindKey_STR(true, szQQGameRegPath, _TEXT("HallDirectory")) )

{

if( ReadKey_STR(true, szQQGameRegPath, _TEXT("HallDirectory"), MAX_PATH, szFullPath) )

{

DeleteAccountFolders(szFullPath, _TEXT("User.cfg"));

LPCTSTR szCfgFile;

if(szDirectory[lstrlen(szFullPath)-1] != TCHAR('\\'))

{

szCfgFile = new const TCHAR[lstrlen(szFullPath)+lstrlen(szQQGameCfgFile)+2];

lstrcpy((LPTSTR)szCfgFile, szFullPath);

lstrcat((LPTSTR)szCfgFile, _TEXT("\\"));

lstrcat((LPTSTR)szCfgFile, szQQGameCfgFile);

}

else

{

szCfgFile = new const TCHAR[lstrlen(szFullPath)+lstrlen(szQQGameCfgFile)+1];

lstrcpy((LPTSTR)szCfgFile, szFullPath);

lstrcat((LPTSTR)szCfgFile, szQQGameCfgFile);

}

DeleteFile(szCfgFile);

}

}

return true;

}

catch(...)

{

return false;

}

}

bool ClearMSNHistory(void) //清理MSN账户文件夹

{

try

{

LPCTSTR szFullPath, szDirectory;

LPCTSTR* szSubKeysList;

DWORD dwListLen;

LPCTSTR szMSNRegPath = _TEXT("Software\\Microsoft\\MSNMessenger\\PerPassportSettings\\");

LPCTSTR szMSNUserPath = _TEXT("Software\\Microsoft\\IdentityCRL\\");

LPCTSTR szMSNUserPathEx = _TEXT("Creds\\");

LPCTSTR szMSNUserMajor = _TEXT("ConfigMajorVersion");

LPCTSTR szMSNUserMinor = _TEXT("ConfigMinorVersion");

szFullPath = new const TCHAR[lstrlen(szMSNUserPath)+lstrlen(szMSNUserPathEx)+1];

lstrcpy((LPTSTR)szFullPath, szMSNUserPath);

lstrcat((LPTSTR)szFullPath, szMSNUserPathEx);

SHDeleteKey(HKEY_CURRENT_USER, szFullPath);

DeleteKey(false, szMSNUserPath, szMSNUserMajor);

DeleteKey(false, szMSNUserPath, szMSNUserMinor);

if( ReadKey_SUBKEYS(false, szMSNRegPath, MAX_PATH, szSubKeysList, dwListLen) )

{

for(DWORD nCount=0; nCount

{

if( lstrcmp(szSubKeysList[nCount], _TEXT("0")) == 0 )

{

continue;

}

if(szSubKeysList[nCount][lstrlen(szSubKeysList[nCount])-1] != TCHAR('\\'))

{

szFullPath = new const TCHAR[lstrlen(szMSNRegPath)+lstrlen(szSubKeysList[nCount])+2];

memset((LPTSTR)szFullPath, TCHAR('\0'), lstrlen(szMSNRegPath)+lstrlen(szSubKeysList[nCount])+2);

lstrcpy((LPTSTR)szFullPath, szMSNRegPath);

lstrcat((LPTSTR)szFullPath, szSubKeysList[nCount]);

lstrcat((LPTSTR)szFullPath, _TEXT("\\"));

}

else

{

szFullPath = new const TCHAR[lstrlen(szMSNRegPath)+lstrlen(szSubKeysList[nCount])+1];

memset((LPTSTR)szFullPath, TCHAR('\0'), lstrlen(szMSNRegPath)+lstrlen(szSubKeysList[nCount])+1);

lstrcpy((LPTSTR)szFullPath, szMSNRegPath);

lstrcat((LPTSTR)szFullPath, szSubKeysList[nCount]);

}

if( FindKey_STR(false, szFullPath, _TEXT("MessageLogPath")) )

{

szDirectory = new const TCHAR[MAX_PATH*2];

memset((LPTSTR)szDirectory, TCHAR('\0'), MAX_PATH*2);

if( ReadKey_STR(false, szFullPath, _TEXT("MessageLogPath"), MAX_PATH*2, szDirectory) )

{

DeleteFolder(szDirectory);

}

}

SHDeleteKey(HKEY_CURRENT_USER, szFullPath);

}

}

else

{

return false;

}

return true;

}

catch(...)

{

return false;

}

}

bool DeleteAccountFolders(LPCTSTR szDirectory, LPCTSTR szListFileName) //删除所有的号码文件夹

{

try

{

if( !::PathFileExists(szDirectory) )

{

return false;

}

LPCTSTR szSerach;

if(szDirectory[lstrlen(szDirectory)-1] != TCHAR('\\'))

{

szSerach = new const TCHAR[lstrlen(szDirectory)+5];

memset((LPTSTR)szSerach, TCHAR('\0'), lstrlen(szDirectory)+5);

lstrcpy((LPTSTR)szSerach, szDirectory);

lstrcat((LPTSTR)szSerach, _TEXT("\\*.*"));

}

else

{

szSerach = new const TCHAR[lstrlen(szDirectory)+4];

memset((LPTSTR)szSerach, TCHAR('\0'), lstrlen(szDirectory)+4);

lstrcpy((LPTSTR)szSerach, szDirectory);

lstrcat((LPTSTR)szSerach, _TEXT("*.*"));

}

WIN32_FIND_DATA wfd;

HANDLE hFind;

if ((hFind = FindFirstFile(szSerach, &wfd)) == INVALID_HANDLE_VALUE)

{

return false;

}

LPCTSTR szFullPath;

bool bNeedDelete;

do

{

bNeedDelete = true;

if( (lstrcmp(wfd.cFileName, _TEXT("0")) == 0)(lstrcmp(wfd.cFileName, _TEXT("\\0")) == 0) ) //"0"是非凡文件夹

{

continue;

}

szFullPath = new const TCHAR[lstrlen(szDirectory)+lstrlen(wfd.cFileName)+1];

memset((LPTSTR)szFullPath, TCHAR('\0'), lstrlen(szDirectory)+lstrlen(wfd.cFileName)+1);

lstrcpy((LPTSTR)szFullPath, szDirectory);

lstrcat((LPTSTR)szFullPath, wfd.cFileName);

if(FALSE == PathIsDirectory(szFullPath)) //是否是文件夹

{

if( _tcsicmp(wfd.cFileName, szListFileName) == 0 ) //号码列表文件

{

DeleteFile(szFullPath);

}

continue;

}

for(u_short nCount=0; nCount

{

if( (wfd.cFileName[nCount] TCHAR('9')) ) //是否为纯数字

{

if(wfd.cFileName[nCount] != TCHAR('\\'))

{

bNeedDelete = false;

break;

}

}

}

if(bNeedDelete)

{

DeleteFolder(szFullPath);

}

}

while( FindNextFile(hFind, &wfd) );

return true;

}

catch(...)

{

return false;

}

}

bool DeleteFolder(LPCTSTR szFolderName) //删除某个文件夹

{

try

{

if( (!::PathFileExists(szFolderName))(FALSE == PathIsDirectory(szFolderName)) )

{

return false;

}

LPCTSTR szNewFolderName;

if(szFolderName[lstrlen(szFolderName)-1] == TCHAR('\\'))

{

szNewFolderName = new const TCHAR[lstrlen(szFolderName)+1];

memset((LPTSTR)szNewFolderName, TCHAR('\0'), lstrlen(szFolderName)+1); //szNewFolderName 后面需要两个字串结束符

_tcsncpy((LPTSTR)szNewFolderName, szFolderName, lstrlen(szFolderName)-1);

}

else

{

szNewFolderName = new const TCHAR[lstrlen(szFolderName)+2];

memset((LPTSTR)szNewFolderName, TCHAR('\0'), lstrlen(szFolderName)+2); //szNewFolderName 后面需要两个字串结束符

_tcscpy((LPTSTR)szNewFolderName, szFolderName);

}

SHFILEOPSTRUCT fos;

ZeroMemory(&fos, sizeof(fos));

fos.hwnd = HWND_DESKTOP;

fos.wFunc = FO_DELETE;

fos.fFlags = FOF_SILENTFOF_NOCONFIRMATIONFOF_NOERRORUI;//FOF_ALLOWUNDO;

fos.pFrom = szNewFolderName;

if(SHFileOperation(&fos) == 0)

{

return true;

}

return false;

}

catch( ... )

{

return false;

}

}

******************************************************************************

bool FindKey_STR(bool RegRootFlag, LPCTSTR RegPath, LPCTSTR theKey)

{

HKEY hKEY;

try

{

long lRet;

if(RegRootFlag)

{

lRet = (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegPath, 0, KEY_QUERY_VALUE, &hKEY));

}

else

{

lRet = (::RegOpenKeyEx(HKEY_CURRENT_USER, RegPath, 0, KEY_QUERY_VALUE, &hKEY));

}

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

return false;

}

DWORD dwKeyType = REG_SZ;

lRet =::RegQueryValueEx(hKEY, theKey, NULL, &dwKeyType, NULL, NULL);

if( lRet != ERROR_SUCCESS )

{

::RegCloseKey(hKEY);

return false;

}

::RegCloseKey(hKEY);

return true;

}

catch( ... )

{

::RegCloseKey(hKEY);

return false;

}

}

bool ReadKey_STR(bool RegRootFlag, LPCTSTR RegPath, LPCTSTR theKey, DWORD KeyLength, LPCTSTR &theKeyValue)

{

HKEY hKEY;

KeyLength = (KeyLength+1)*sizeof(TCHAR);

LPBYTE lpKeyValue = new BYTE[KeyLength];

try

{

long lRet;

if(RegRootFlag)

{

lRet = (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegPath, 0, KEY_READ, &hKEY));

}

else

{

lRet = (::RegOpenKeyEx(HKEY_CURRENT_USER, RegPath, 0, KEY_READ, &hKEY));

}

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

DWORD dwKeyType = REG_SZ;

if(KeyLength == 0)

{

KeyLength = 5;

}

lRet =::RegQueryValueEx(hKEY, theKey, NULL, &dwKeyType, lpKeyValue, KeyLength);

if( lRet == ERROR_MORE_DATA )

{

LPBYTE lpKeyValue = new BYTE[KeyLength];

lRet =::RegQueryValueEx(hKEY, theKey, NULL, &dwKeyType, lpKeyValue, KeyLength);

}

theKeyValue = (LPCTSTR)lpKeyValue;

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

::RegCloseKey(hKEY);

//delete[] lpKeyValue;

return true;

}

catch( ... )

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

}

bool WriteKey_STR(bool RegRootFlag, LPCTSTR RegPath, LPCTSTR theKey, DWORD KeyLength, LPCTSTR theKeyValue)

{

HKEY hKEY;

KeyLength = (KeyLength+1)*sizeof(TCHAR);

const BYTE* lpKeyValue = (LPBYTE)theKeyValue;

try

{

long lRet;

DWORD dwDisposition;

if(RegRootFlag)

{

lRet = (::RegCreateKeyEx(HKEY_LOCAL_MACHINE, RegPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKEY, &dwDisposition));

}

else

{

lRet = (::RegCreateKeyEx(HKEY_CURRENT_USER, RegPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKEY, &dwDisposition));

}

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

DWORD dwKeyType = REG_SZ;

if(KeyLength == 0)

{

KeyLength = 260;

}

lRet =::RegSetValueEx(hKEY, theKey, NULL, dwKeyType, lpKeyValue, KeyLength);

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

return true;

}

catch( ... )

{

::RegCloseKey(hKEY);

delete[] lpKeyValue;

return false;

}

}

bool DeleteKey(bool RegRootFlag, LPCTSTR RegPath, LPCTSTR theKey)

{

HKEY hKEY;

try

{

long lRet;

if(RegRootFlag)

{

lRet = (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegPath, 0, KEY_ALL_Access, &hKEY));

}

else

{

lRet = (::RegOpenKeyEx(HKEY_CURRENT_USER, RegPath, 0, KEY_ALL_ACCESS, &hKEY));

}

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

return false;

}

lRet =::RegDeleteValue(hKEY, theKey);

::RegCloseKey(hKEY);

return true;

}

catch( ... )

{

::RegCloseKey(hKEY);

return false;

}

}

bool ReadKey_SUBKEYS(bool RegRootFlag, LPCTSTR RegPath, DWORD SubKeyLength, LPCTSTR* &theKeysList, DWORD &ListLen)

{

HKEY hKEY;

try

{

long lRet;

if(RegRootFlag)

{

lRet = (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegPath, 0, KEY_ENUMERATE_SUB_KEYS, &hKEY));

}

else

{

lRet = (::RegOpenKeyEx(HKEY_CURRENT_USER, RegPath, 0, KEY_ENUMERATE_SUB_KEYS, &hKEY));

}

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

return false;

}

ListLen = 0;

DWORD dwPreLen = SubKeyLength;

LPTSTR lpName;

lpName = new TCHAR[SubKeyLength];

memset(lpName, TCHAR('\0'), SubKeyLength);

while( ::RegEnumKeyEx(hKEY, ListLen, lpName, &SubKeyLength, NULL, NULL, NULL, NULL) == ERROR_SUCCESS )

{

SubKeyLength = dwPreLen;

ListLen++;

}

if(ListLen == 0)

{

::RegCloseKey(hKEY);

return false;

}

theKeysList = new LPCTSTR[ListLen];

for(DWORD nCount=0; nCount

{

SubKeyLength = dwPreLen;

theKeysList[nCount] = new const TCHAR[SubKeyLength];

memset((LPTSTR)theKeysList[nCount], TCHAR('\0'), SubKeyLength);

lRet = ::RegEnumKeyEx(hKEY, nCount, (LPTSTR)theKeysList[nCount], &SubKeyLength, NULL, NULL, NULL, NULL);

if(lRet != ERROR_SUCCESS)

{

::RegCloseKey(hKEY);

return false;

}

}

return true;

}

catch(...)

{

return false;

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有