VC中实现历史记录的全面清除
2009-10-15 20:31:28 来源:WEB开发网2、Cookie的清除
TCHAR szPath[MAX_PATH];
DeleteUrlCache(Cookie);
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_COOKIES, FALSE))
{//得到目录,并清空
EmptyDirectory(szPath);
}
3、浏览器地址栏历史地址的清除
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\TypedURLs"));
4、清除表单自动完成历史记录
CString sKey;
DWORD dwRet;
if (IsWindows2k() || IsWindowsNT())//先判断系统
{
CString sBaseKey;
SECURITY_DESCRIPTOR NewSD;
BYTE* pOldSD;
PACL pDacl = NULL;
PSID pSid = NULL;
TCHAR szSid[256];
if (GetUserSid(&pSid))
{
//get the hiden key name
GetSidString(pSid, szSid);
sKey = _T("Software\\Microsoft\\Protected Storage System Provider\\");
sKey += szSid;
//get old SD
sBaseKey = sKey;
GetOldSD(HKEY_CURRENT_USER, sBaseKey, &pOldSD);
//set new SD and then clear
if (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 SD
if (pOldSD)
{
RegSetPrivilege(HKEY_CURRENT_USER, sBaseKey,
(SECURITY_DESCRIPTOR*)pOldSD, FALSE);
delete pOldSD;
}
}
if (pSid)
HeapFree(GetProcessHeap(), 0, pSid);
}
//win9x
DWORD 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、清除自动密码历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\IntelliForms"));
更多精彩
赞助商链接