Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get a (gif-)picture in a stringvar
Message
De
11/05/2010 12:50:18
 
 
À
11/05/2010 12:45:27
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01464184
Message ID:
01464186
Vues:
72
This message has been marked as the solution to the initial question of the thread.
lcURL="http://statisch.marktplaats.com/get_image.php/AvFH460LGDPNJ0XNqshMU3kEb25q8xfF5NDYUHb9TTd4hCzcv7ECt53a44Auo+XWuxNr22MIz2w="
lcGigdata=GetDataFromRUL(lcURL)

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 )

* return the URL contents
RETURN lcRetVal
>Hello all
>
>I have a gif-picture at a internet address, which I want to store in a VFP-variable:
>
>This is my code so far:
>
>oIE = CREATEOBJECT("InternetExplorer.Application")
>oIE.Visible = .t.
>oIE.Navigate("http://statisch.marktplaats.com/get_image.php/AvFH460LGDPNJ0XNqshMU3kEb25q8xfF5NDYUHb9TTd4hCzcv7ECt53a44Auo+XWuxNr22MIz2w=")
>
>
>When I do the following statement:
>
>? oIE.document.body.innerhtml
>
>
>I get:
>
><IMG src= "http://statisch.marktplaats.com/get_image.php/AvFH460LGDPNJ0XNqshMU3kEb25q8xfF5NDYUHb9TTd4hCzcv7ECt53a44Auo+XWuxNr22MIz2w=">
>
>
>I got stuck here. How do I get the bytes that make up the gif in a variable?
>
>TIA,
>
>Lennert
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform