Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I get VFP to clear my web cache
Message
De
05/09/2007 05:19:28
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01252364
Message ID:
01252365
Vues:
70
>In my program is the following code - if I don't manually clear my Internet cache then the pages are downloaded from cache - how can I clear the cache by program?
>
>Thanks
>
>Colin
>
>
>CREATE CURSOR WebPage (myMails m)
>set century on
>url="http://www.timeanddate.com/worldclock/full.html"
>objHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
>objHTTP.Open("GET", url,.f.)
>objHTTP.Send()
>Insert into WebPage (myMails) VALUES (objHTTP.ResponseText)
>objHTTP = null
>RELEASE objHTTP

Try this function insetad
Function getdatafromurl
  Lparameters pcUrlName
  Declare Integer InternetOpen In wininet.Dll String sAgent, ;
    INTEGER lAccessType, String sProxyName, ;
    STRING sProxyBypass, Integer lFlags

  Declare Integer InternetOpenUrl In wininet.Dll ;
    INTEGER hInternetSession, String sUrl, String sHeaders,;
    INTEGER lHeadersLength, Integer lFlags, Integer lContext

  Declare Integer InternetReadFile In wininet.Dll Integer hfile, ;
    STRING @sBuffer, Integer lNumberofBytesToRead, Integer @lBytesRead

  Declare short InternetCloseHandle In wininet.Dll Integer hInst

  #Define INTERNET_OPEN_TYPE_PRECONFIG 0
  #Define INTERNET_OPEN_TYPE_DIRECT 1
  #Define INTERNET_OPEN_TYPE_PROXY 3
  #Define SYNCHRONOUS 0
  #Define INTERNET_FLAG_RELOAD 2147483648
  #Define CR Chr(13)

  Local lsAgent, lhInternetSession, lhUrlFile, llOk, lnOk, lcRetVal, lcReadBuffer, lnBytesRead

* what application is using Internet services?
  lsAgent = "VPF 5.0"

  lhInternetSession = InternetOpen( lsAgent, INTERNET_OPEN_TYPE_PRECONFIG, ;
    '', '', SYNCHRONOUS)

* debugging line - uncomment to see session handle
* WAIT WINDOW "Internet session handle: " + LTRIM(STR(hInternetSession))

  If lhInternetSession = 0
    Wait Window "Internet session cannot be established" Time 2
    Return .Null.
  Endif

  lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, ;
    INTERNET_FLAG_RELOAD, 0)

* debugging line - uncomment to see URL handle
* WAIT WINDOW "URL Handle: " + LTRIM(STR(hUrlFile))

  If lhUrlFile = 0
    Wait Window "URL cannot be opened"
    Return .Null.
  Endif

  lcRetVal = ""
  llOk = .T.

  Do While llOk
* set aside a big buffer
    lsReadBuffer = Space(32767)
    lnBytesRead = 0
    lnOk = InternetReadFile( lhUrlFile, @lsReadBuffer, Len(lsReadBuffer), @lnBytesRead)

    If ( lnBytesRead > 0 )
      lcRetVal = lcRetVal + Left( lsReadBuffer, lnBytesRead )
    Endif

* error trap - either a read failure or read past eof()
    llOk = ( lnOk = 1 ) And ( lnBytesRead > 0 )
  Enddo

* close all the handles we opened
  InternetCloseHandle( lhUrlFile )
  InternetCloseHandle( lhInternetSession )
  Clear Dlls InternetOpen,InternetCloseHandle,InternetOpenUrl ,InternetReadFile
* return the URL contents
Return lcRetVal
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform