FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Download a file
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Download a file

Posted: Sun Sep 01, 2019 08:37 PM

Do you have a small script for dowload a file from a site ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: Download a file

Posted: Sun Sep 01, 2019 09:37 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Download a file

Posted: Mon Sep 02, 2019 06:32 AM
Christobal,

I got the error unresolved external

URLDownloadToFile
I think it will work only with HARBOUR not xHARBOUR

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: Download a file

Posted: Mon Sep 02, 2019 08:07 AM
error with harbour
Code (fw): Select all Collapse
Progetto: nages, Ambiente: bcc7xHarbor:
[1]:Harbour.Exe nages.prg  /m /n0 /gc1 /es2 /a /iC:\Work\fwh\include /iC:\work\XHARBOUR\Include /jI18n\Main.hil /iinclude;c:\work\fwh\include;C:\work\XHARBOUR\include /oObj\nages.c
xHarbour 1.2.3 Intl. (SimpLex) (Build 20180217)
Copyright 1999-2017, http://www.xharbour.org <!-- m --><a class="postlink" href="http://www.harbour-project.org/">http://www.harbour-project.org/</a><!-- m -->
Compiling 'nages.prg'...
Generating international list to 'I18n\Main.hil'...
Generating C source output to 'Obj\nages.c'...
Done.
Lines 149, Functions/Procedures 3, pCodes 594
[1]:Bcc32.Exe -M -c -DHB_OS_WIN_32 -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -IC:\Work\fwh\include -IC:\work\bcc7\Include\windows\sdk\;C:\work\XHARBOUR\Include  -nObj Obj\nages.c
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
Obj\nages.c:
[1]:iLink32.Exe -Gn -aa -Tpe -s -v @nages.bcl
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external 'URLDownloadToFileA' referenced from C:\WORK\ERRORI\LOTTO\OBJ\NAGES.OBJ
Error: Unable to perform link



I tried also this source
Code (fw): Select all Collapse
  #include "fivewin.ch"

        function Main()
                LOCAL   nRet
               
                nRet := DOWNLOADFILE( "https://www.lottomatica.it/STORICO_ESTRAZIONI_LOTTO/storico.zip", "C:\" )
               
                MsgStop( nRet )
        RETURN NIL


         #pragma BEGINDUMP

    #include <Windows.h>
    #include <hbapi.h>
    #include <urlmon.h>

    HB_FUNC( DOWNLOADFILE )

    {
            HRESULT hr;

            hr = URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) ;

            hb_retnl( hr ) ;
    }

    #pragma ENDDUMP





How decompress a file zip I downloaded ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 153
Joined: Tue Aug 05, 2014 09:48 AM

Re: Download a file

Posted: Mon Sep 02, 2019 09:30 AM

Hi
You have to add urlmon library

Regards, Greetings



Try FWH. You will enjoy it's simplicity and power.!
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: Download a file

Posted: Mon Sep 02, 2019 09:39 AM
Now I foud a script run ok
Code (fw): Select all Collapse
 #include "fivewin.ch"

function DescargFichDesdeUrl()
   Local cdate:=dtoc(date())
   local cFile := "C:\Work\Errori\download\storico_.zip"
   local cUrl  := "https://www.lottomatica.it/STORICO_ESTRAZIONI_LOTTO/storico.zip"

    DELETEURLCACHEENTRY( cUrl )

    URLDOWNLOADTOFILE( 0, cUrl, cFile )
 
RETURN NIL

DLL STATIC FUNCTION DELETEURLCACHEENTRY( cUrl AS LPSTR ) AS BOOL;
    PASCAL FROM "DeleteUrlCacheEntryA" LIB "wininet.dll"

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG, cUrl AS LPSTR, cFileName AS LPSTR, nReserved AS DWORD, nFnCB AS LONG ) AS LONG;
    PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Download a file

Posted: Mon Sep 02, 2019 10:36 AM
Silvio,

YES works perfect

a download-test from my website

LOCAL cSaveAs := "I:\_Download\download\Store_.zip"
LOCAL cUrl := "http://www.Pflegeplus.com/DOWNLOADS/Gditest1.zip"


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion