Discussion:
FindFirstUrlCacheEntry
(too old to reply)
Lubomir
2006-12-20 00:05:00 UTC
Permalink
Hi,

I would like to ask if there are any functions aplicable to the other user
then the current user.
Functions like FindFirstUrlCacheEntry operate on the current user's files.
For example, is there any API for enumerating users' XXX Temporary Internet
Files? I could not fine any in MSDN, and I am not sure if just browsing
users's XXX cookies, internet files, ... with standard Win API functions
FindFirstFile would be the proper way to do it. Especially, if I want to
delete some of those files.

Thanks,
Lubomir
Vladimir Scherbina
2006-12-28 20:16:51 UTC
Permalink
In this case impresonation should be used. However, the functions you
mentioned do not allow to pass any tokens. So, there is not way "to
impersonate" them.
--
Vladimir (Windows SDK MVP)
http://msmvps.com/blogs/v_scherbina/
Post by Lubomir
Hi,
I would like to ask if there are any functions aplicable to the other user
then the current user.
Functions like FindFirstUrlCacheEntry operate on the current user's files.
For example, is there any API for enumerating users' XXX Temporary Internet
Files? I could not fine any in MSDN, and I am not sure if just browsing
users's XXX cookies, internet files, ... with standard Win API functions
FindFirstFile would be the proper way to do it. Especially, if I want to
delete some of those files.
Thanks,
Lubomir
null
2007-01-22 22:17:36 UTC
Permalink
Post by Lubomir
Hi,
I would like to ask if there are any functions aplicable to the other user
then the current user.
Functions like FindFirstUrlCacheEntry operate on the current user's files.
For example, is there any API for enumerating users' XXX Temporary Internet
Files? I could not fine any in MSDN, and I am not sure if just browsing
users's XXX cookies, internet files, ... with standard Win API functions
FindFirstFile would be the proper way to do it. Especially, if I want to
delete some of those files.
Thanks,
Lubomir
I use the following the delete all of the temporary internet files
except the cookies.


// Borrowed from
http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c1245/
//
// Delete all files in the Temporary Internet Files folder
//
// Note that you can specify what NOT to delete by testing entry type
// In code below, cookie entries are not deleted
// [see if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))]
//
bool DelTempFiles(bool DeleteCookies)
{
bool bResult = false;
bool bDone = false;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = 0;

DWORD dwTrySize, dwEntrySize = 4096; // start buffer size
HANDLE hCacheDir = 0;
DWORD dwError = ERROR_INSUFFICIENT_BUFFER;

do
{
switch (dwError)
{
// Need a bigger buffer.
case ERROR_INSUFFICIENT_BUFFER:
delete [] lpCacheEntry;
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
dwTrySize = dwEntrySize;
bool bSuccess;
if (hCacheDir == 0)
bSuccess = (hCacheDir =
FindFirstUrlCacheEntry(0,lpCacheEntry,&dwTrySize)) != 0;
else
bSuccess =
FindNextUrlCacheEntry(hCacheDir,lpCacheEntry,&dwTrySize);
if (bSuccess)
dwError = ERROR_SUCCESS;
else
{
dwError = GetLastError();
dwEntrySize = dwTrySize; // Use new size returned.
}
break;
// We are done.
case ERROR_NO_MORE_ITEMS:
bDone = true;
bResult = true;
break;
// We have got an entry.
case ERROR_SUCCESS:
// Test for cookie entry.
if (DeleteCookies ||
!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
// Get ready for next entry.
dwTrySize = dwEntrySize;
if (FindNextUrlCacheEntry(hCacheDir,lpCacheEntry,&dwTrySize))
dwError = ERROR_SUCCESS;
else
{
dwError = GetLastError();
dwEntrySize = dwTrySize; // Use new size returned.
}
break;
// Unknown error.
default:
bDone = true;
break;
}
if (bDone)
{
delete [] lpCacheEntry;
if (hCacheDir)
FindCloseUrlCache(hCacheDir);
}
} while (!bDone);
return bResult;
}

Loading...