Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to automate getting a file from the web
Message
From
26/10/2005 17:43:38
 
 
To
26/10/2005 17:39:16
General information
Forum:
Visual FoxPro
Category:
Internet applications
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01050252
Message ID:
01062431
Views:
17
Tore
Thanks anyway.

Maybe someone else out there may know.

Barry.

>Barry,
>
>Sorry, I have no clue, but it's probably a security issue. I am not the originator of this function, which I have used successfully for a few years.
>
>>Tore
>>
>>I wonder if you can help? Not strictly VFP question, but very much an issue that has caused me a problem in my VFP application:
>>
>>I have used the code you list very successfully for a few years now. Recently we installed Windows Small Business Server 2003 on our server and this has ISA2004 installed too. When my code gets to the following line it hangs:
>>
>>
>>lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, ;
>>  INTERNET_FLAG_RELOAD, 0)
>>
>>
>>
>>I think it is something to do with not being able to get out through ISA2004. Have you come across this or have any idea what it could be that is causing it to hang. The same code works fine on my home pc which does not have the same firewall setup.
>>
>>Thank you
>>Barry Sutton
>>
>>
>>
>>
>>
>>
>>>>I need to retrieve a text file from the internet. How do I get FoxPro 6.0 to download the below file without user intervention?
>>>>
>>>>http://www.fededirectory.frb.org/FedACHdir.txt
>>>>
>>>>Scott Sherman
>>>
>>>Short version, with minimal error handling
>>>Function getfilefromurl
>>>Lparameters lcRemoteFile,lcLocalFile
>>>Local lnReturn
>>>Declare Integer URLDownloadToFile In urlmon.Dll;
>>>  INTEGER pCaller, String szURL, String szFileName,;
>>>  INTEGER dwReserved, Integer lpfnCB
>>>lnReturn = URLDownloadToFile (0, lcRemoteFile, lcLocalFile, 0, 0)
>>>Return lnReturn=0
>>>
>>>Long version
>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform