Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read cache files and read URL from Opened IE 1

Status
Not open for further replies.

tamayok

Programmer
Sep 4, 2001
99
0
0
PR
Hi,

I need to be able to do 2 things:

> Determine if a FILE() exists in the Temporary Internet Files / Cache 'folder' and FILETOSTR() its content if it does.

I've tried many approaches (Using FILE(), ADIR(), FILETOSTR(), adding a MyFile[1] name...) but nothing seems to work.

Code:
** XP
? FILE("C:\Documents and Settings\"+(SUBSTR(SYS(0),AT("#",SYS(0))+2,LEN(SYS(0))))+"\Local Settings\Temporary Internet Files\"+"EmployerMain.htm",1)

** W7-8
? FILE("C:\Users\"+(SUBSTR(SYS(0),AT("#",SYS(0))+2,LEN(SYS(0))))+"\AppData\Local\Microsoft\Windows\Temporary Internet Files\"+"EmployerMain.htm",1)

I can see there is Win API function referenced by the site News2News that might help (declaration below) but have not been able to get it to work either.

Code:
DECLARE INTEGER GetUrlCacheEntryInfo IN wininet;
    STRING    lpszUrlName,;
    STRING  @ lpCacheEntryInfo,;
    INTEGER @ lpdwCacheEntryInfoBufferSize
 
The Cache does not cache everything. I just tried and called a page, then checked the cache and only found pictures cached. You also find HTML files in the cache, but what IE caches depends on several things not under your control. I'd not look into the cache for any file anyway, simply revisit a URL, if it's cachable and it's expiration date not yet passed, IE will fetch it from the cache anywway, you don't need to operate the cache, IE will do so.

use or faq184-3838
or faq184-3019
or the MsXml2.XmlHttp class
or ...

Anything to download a URL will make use of cache and/or proxy anyway.

Also news2news offers a usage example for the function you found (any news2news declaration entry also has a section with free and subscriber samples), see
Bye, Olaf.
 
>read URL from Opened IE

On that aspect: As long as you automate IE as in eg
Code:
Public goIE
goIE = CreateObject("InternetExplorer.Application")
goIE.visible=.T.
At any time you can read goIE.LocationURL.

But: If IE creates a new process for a new tab, your goIE will not see these tabs, only the first one. And if that's closed your goIE reference will be a "zombie" object. And as users use tabs that's likely to happen.

There are tools like this:
Bye, Olaf.
 
This doesn't answer your question, but I would advise against hard-coding specific paths, such as "C:\Documents and Settings\" and "C:\Users\". Even though your code correctly distinguishes these paths for Windows XP and Windows 7 respectively, you never know what changes Microsoft might introduce in future versions of Windows.

There are API functions that will locate these folders for you. Look for SHGetSpecialFolderLocation() on News2News. And see for an example of how to use it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike,

I like your GetSpecial function based on Win API is much better than the one I have been using (which relies on WScript.Shell and a call to WSHShell.SpecialFolders(cSpecialFolder) for which I couldn't find an Internet_Cache directive). Your link to [URL unfurl="true"]http://code.snapstream.com/api/bm11/SnapStream.Util.CSIDL.html[/url] shows INTERNET_CACHE as 32, which works beautifully.

Thanks OlafDoschke,

Those are interesting links but I am not being able to do much with them since I am not automating IE. The user may or may not call one of the (cache-friendly) pages I am being asked to monitor. Normally, a similar request from a client would have me scan the Task Processes or Windows Captions/Names but to complicate matters in this case I must also distinguish between 2 web apps that use the same web-title. By reading the text in the target stored Temporary Internet File (an ASPX that copies from Windows Explorer as an HTM file), I can easily and unequivocally tell one page from the other. The problem is I can't even find out if the 'file' exists in the cache folder using the FILE() function, much less read the text from it or copy it programmatically (a drag-drop operation using Windows Explorer works fine... just converts the .ASPX file to .HTM and inserts a '[1]' to the stem name) elsewhere were I could easily do this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top