Recently, TWEBBROWSERs have recently used TWebBrowser to get a list of trading. The specific process is that after the customer clicks the query button, use TWebBrowser to access an XML page of the bank to get the trading list information. Soon, the system is completed, and after testing, the transaction list shows normal, it seems to be able to work.
In the afternoon of the customer decided to tried online, suddenly found: I have made a transaction, visit the transaction record, um, everything is normal; make a transaction, visit the transaction record, um? Can't find the transaction you just made. Let's make a transaction, or this. There is no doubt that there is BUG. Turning the head, I saw the eyes of the customers, and I know that I didn't wait.
Time urgent, quickly find the problem, use IE to access the XML page, there are two transactions, indicating that the transaction is successful, and the trading list is normal, troubleshoot, there is no problem, what is going on?
Open the software, query the transaction, normal, and have these two days of transaction records. Re-query, there is no new transaction. Exit the software and re-run, the trading list is normal, here, things are a bit clear, just run the software, access this page, normal, and then access this page result is the first visit. Is this the legendary IE Cache function?
The problem found, using TWebBrowser to access the same URL in the same process, I will use IE's cache function, now I will find how to solve it. There are two ways: First, use control attributes or methods to control IE to browse the cache functionality when browsing the page. Create a new project, put the TWEBBBROWSER, TWEBBROWSEREX, TEMBEDDEDWB, and set the property, test. Without any effect, IE's Cache functionality like a nightmare generally shows amazing perseverance.
There is no extra time to study slowly, only to try another method, that is, before the TWebBrowser browsing the page, first clear the cache of the page, there is no doubt that it is time to use the API, open MSDN, search for cache, I have seen it several times and aimed at DeleteURLCACHEENTRY.
Take a look at its definition:
Bool
Deleteurlcachentry
LPCTSTR
Lpszurlname
); Then look at the description: Removes The File Associated with the source name from the cache, if the file exists.
Yes, it is, it is okay, from 98 to XP full support, immediately add DeleteURLCACHEENTRY calls before TWebBrowser, don't forget to add Wininet unit reference. Test, OK, normal.
Looking back, IE has a very 8-wrong Cache function with a small trap, and this trap is solved, but the ingredientscent, but the sky knows how much such "trap" is waiting for us. .