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;
}
}