Introduction
This easy method uses Wininet
DLL to read a cache file. The demo uses a class object.
This algorithm requires use of InternetOpen
function to initialize the DLL to read from the cache. INTERNET_FLAG_FROM_CACHE
setting forces a new download of the requested files in calls to InternetOpenURL
with a URL set. It reads the file and returns it. It closes all handles.
Private Const INTERNET_OPEN_TYPE_DIRECT = &H1
Private Const INTERNET_FLAG_FROM_CACHE = &H40
Public Function ReadCacheFile(url As String) As String
Dim l&, Buffer$, hOpen&, hFile&, Result&
l = 32768
Buffer = Space(l)
DoEvents
hOpen = InternetOpen(UserAgent, INTERNET_OPEN_TYPE_DIRECT, _
vbNullString, vbNullString, INTERNET_FLAG_FROM_CACHE)
hFile = InternetOpenUrl(hOpen, url, vbNullString, _
ByVal 0&, &0, _
ByVal 0&)
Call InternetReadFile(hFile, Buffer, l, Result&)
Call InternetCloseHandle(hFile)
Call InternetCloseHandle(hOpen)
ReadCacheFile = Left$(StrConv(Buffer, vbUnicode), Result&)
End Function
This line is useful for obtaining unfiltered data such as for getting an applet:
ReadCacheFile = Left$(StrConv(Buffer, vbUnicode), Result&)
In the case of an applet, with conversion to UNICODE it works, without the conversion it will not.
History
- 21st December, 2003: Initial post
Hubris is like armor. He is afraid to take on a Coder project for what it may do to him, both financially and to his health.
WEB Bowser is a hack that makes it easy to acquire internet content for archival. Its also possible to PROXY it, serving it to the internet as well. Given this capability, people will change the internet again.
I envision a programmable server that will acquire content for proxy. Users will then add proxy content to their own, making it available almost as if it were their own. We are already "information collectors." Its the opinions that are getting real hard to find.
-