Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WebBrowser Control, prevent picture download.
Message
From
14/05/2007 05:22:16
 
 
To
14/05/2007 04:27:11
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01225139
Message ID:
01225148
Views:
16
>Hello,
>I using a webbrowser contol in hidden mode to automate internet site. Is it possible to prevent pictures download only for current browser session? Its can accelerate this automation in many times!
>
>Any ideas,
>Thanks

I don't know if this is usable for you, but here are two functions I use to download from internet addresses.
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

  INTERNET_OPEN_TYPE_PRECONFIG =0
  INTERNET_OPEN_TYPE_DIRECT =1
  INTERNET_OPEN_TYPE_PROXY =3
  SYNCHRONOUS =0
  INTERNET_FLAG_RELOAD =2147483648
  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" TIMEOUT 1
    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
ENDFUNC
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
Previous
Reply
Map
View

Click here to load this message in the networking platform