View Issue Details

IDProjectCategoryView StatusLast Update
0000721KCleanerNew Featurepublic2008-08-27 17:39
ReporterKyle_Katarn Assigned ToKyle_Katarn  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version0.5 
Target VersionFixed in Version0.8 
Summary0000721: Meriadoc's code for Index.dat cleaning
DescriptionMeriadoc's code for Index.dat cleaning
Additional InformationBOOL Delete_IECache(BOOL bDeleteCache = TRUE, BOOL bDeleteCacheIndex = FALSE)

BOOL Delete_IECookies(BOOL bDeleteCookies = TRUE, BOOL bDeleteCookiesIndex = FALSE)

HRESULT Delete_IEHistory(BOOL bDeleteHistory = TRUE, BOOL bDeleteHistoryIndex = FALSE)

>Deleting the files and leaving index.dat or deleting index.dat if the file is not locked
__________________________________________________________________________________________


**Delete_IECache**

__declspec( dllexport ) BOOL Delete_IECache(bDeleteCache =
TRUE, BOOL bDeleteCacheIndex = FALSE)
{
TCHAR szUserProfile[200];
TCHAR szFilePath[200];
HANDLE hCacheEnumHandle = NULL;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;
DWORD dwSize = 4096; // initial buffer size




if (bDeleteCacheIndex)
{
ExpandEnvironmentStrings("%userprofile%", szUserProfile,
sizeof(szUserProfile));
wsprintf(szFilePath, "%s%s", szUserProfile,
"\\Local Settings\\Temporary Internet"
" Files\\Content.IE5\\index.dat");

DeleteFile(szFilePath);

if (!bDeleteCache) return TRUE;
}



lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwSize];
lpCacheEntry->dwStructSize = dwSize;


hCacheEnumHandle = FindFirstUrlCacheEntry(NULL /* in */ ,
lpCacheEntry /* out */,
&dwSize /* in, out */);



if (hCacheEnumHandle != NULL)
{
if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
}
}
else
{
switch (GetLastError())
{
case ERROR_INSUFFICIENT_BUFFER:
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwSize];
lpCacheEntry->dwStructSize = dwSize;



hCacheEnumHandle = FindFirstUrlCacheEntry(NULL, lpCacheEntry,
&dwSize);
if (hCacheEnumHandle != NULL)
{
if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
}
break;
}
else
{
return FALSE;
}
default:
FindCloseUrlCache(hCacheEnumHandle);
return FALSE;
}
}



do
{


if (FindNextUrlCacheEntry(hCacheEnumHandle, lpCacheEntry, &dwSize))
{
if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
}
}
else
{
switch(GetLastError())
{
case ERROR_INSUFFICIENT_BUFFER:
lpCacheEntry =
(LPINTERNET_CACHE_ENTRY_INFO) new char[dwSize];
lpCacheEntry->dwStructSize = dwSize;


if (FindNextUrlCacheEntry(hCacheEnumHandle, lpCacheEntry,
&dwSize))
{
if (!(lpCacheEntry->CacheEntryType &
COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(
lpCacheEntry->lpszSourceUrlName);
}
break;
}
else
{
FindCloseUrlCache(hCacheEnumHandle);
return FALSE;
}
break;
case ERROR_NO_MORE_ITEMS:
FindCloseUrlCache(hCacheEnumHandle);
return TRUE;
default:
FindCloseUrlCache(hCacheEnumHandle);
return FALSE;
}
}
} while (TRUE);
}


____________________________________________________________________
**Delete_IECookies**

Nearly the same as Delete_IECache but use "cookie:" instead of NULL as the first parameter for FindFirstUrlCacheEntry
____________________________________________________________________

**Delete_IEHistory**

__declspec( dllexport ) HRESULT Delete_IEHistory(BOOL bDeleteHistory = TRUE,
BOOL bDeleteHistoryIndex = FALSE)
{
TCHAR szUserProfile[200];
TCHAR szFilePath[200];
HRESULT hr;


if (bDeleteHistoryIndex)
{
ExpandEnvironmentStrings("%userprofile%", szUserProfile,
sizeof(szUserProfile));
wsprintf(szFilePath, "%s%s", szUserProfile,
"\\Local Settings\\History"
"\\History.IE5\\index.dat");
DeleteFile(szFilePath);

if (!bDeleteHistoryIndex) return S_OK;
}

CoInitialize(NULL);

IUrlHistoryStg2* pUrlHistoryStg2 = NULL;
hr = CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC,
IID_IUrlHistoryStg2,
(void**)&pUrlHistoryStg2);
if (SUCCEEDED(hr))
{
hr = pUrlHistoryStg2->ClearHistory();
pUrlHistoryStg2->Release();
}
CoUninitialize();

return hr;
}
TagsNo tags attached.

Issue History

Date Modified Username Field Change
2008-08-21 15:08 Kyle_Katarn New Issue
2008-08-21 15:10 Kyle_Katarn Assigned To => Kyle_Katarn
2008-08-21 15:10 Kyle_Katarn Status new => acknowledged
2008-08-21 15:54 Kyle_Katarn Note Added: 0000418
2008-08-27 17:39 Kyle_Katarn Status acknowledged => resolved
2008-08-27 17:39 Kyle_Katarn Fixed in Version => 0.20
2008-08-27 17:39 Kyle_Katarn Resolution open => fixed