找到了自己 - 用WinINet.lib:http://msdn.microsoft.com/en-gb/library/aa383928.aspx
包括WinINet.lib項目和WinINet.h源
#include <wininet.h>
class CCorrelateAxCtrl::findInCache
{
public:
_bstr_t cachedUrl;
findInCache(_bstr_t localName)
{
_findInCache(localName);
}
virtual ~findInCache() {}
private:
int _continue;
DWORD _dwEntrySize;
static const DWORD MAX_CACHE_ENTRY_INFO_SIZE = 4096;
LPINTERNET_CACHE_ENTRY_INFO _lpCacheEntry;
HANDLE _hCacheDir;
_bstr_t _localName;
void _setCachEntry(DWORD dwEntrySize)
{
_dwEntrySize = dwEntrySize;
_lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[_dwEntrySize];
_lpCacheEntry->dwStructSize = _dwEntrySize;
}
bool _checkFound()
{
if (_lpCacheEntry->lpszLocalFileName!=NULL && _localName.length())
{
if (!wcscmp(_lpCacheEntry->lpszLocalFileName, _localName)) {
cachedUrl = _lpCacheEntry->lpszSourceUrlName;
delete[] _lpCacheEntry;
return true;
}
}
return false;
}
int _checkContinue(DWORD dwEntrySize)
{
DWORD err = GetLastError();
if (err)
{
if (err == ERROR_INSUFFICIENT_BUFFER)
{
delete[]_lpCacheEntry;
_setCachEntry(dwEntrySize);
return 2;
}
else
{
FindCloseUrlCache(_hCacheDir);
return 0;
}
}
return 1;
}
void _findInCache(_bstr_t &localName)
{
_localName = localName;
cachedUrl = "";
_setCachEntry(MAX_CACHE_ENTRY_INFO_SIZE);
while(1)
{
_hCacheDir = FindFirstUrlCacheEntry(NULL, _lpCacheEntry, &_dwEntrySize);
_continue = _hCacheDir ? 1 : _checkContinue(_dwEntrySize);
if (_continue!=2)
break;
}
if (!_continue || _checkFound())
return;
_setCachEntry(MAX_CACHE_ENTRY_INFO_SIZE);
try {
while(1)
{
_continue = FindNextUrlCacheEntry(_hCacheDir, _lpCacheEntry, &_dwEntrySize);
_continue = _continue ? 1 : _checkContinue(_dwEntrySize);
if (_continue==1)
{
if (_checkFound())
break;
}
else if (_continue!=2)
break;
}
}
catch (char * error)
{
_bstr_t test = error;
}
}
};