URL Download to File

Other General Resources like icon sets, sound files etc.,

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

URL Download to File

Post by bpd2000 »

Working example of URLdownloadto file
It finished after expert help from KDJ

Code: Select all

/*
From bpd2000
Expert help from KDJ
*/


#include "hmg.ch"

function Main()

   local Down_Result, cURL := "http://www.hmgforum.com/download/file.php?id=8044"

   Down_Result := DOWNLOADFILE( cURL, HB_CWD() + "Down_file.ZIP" )
                         //file will be downloaded in current directory
  
  If Down_Result = 0 
        MsgStop ( "File " + cURL + hb_osnewline() + "has been downloaded!")
    Else 
        MsgStop ("File not found!")
  EndIf 


RETURN NIL

#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

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

HB_FUNC( DOWNLOADFILE )
{
   HRESULT hr;
        
   hr = URLDownloadToFileW( NULL, HMG_parc( 1 ), HMG_parc( 2 ), 0, NULL );
  
   hb_retnl( hr ) ;
}

#pragma ENDDUMP

Attachments
URLDownloadToFile.rar
(1.21 MiB) Downloaded 580 times
BPD
Convert Dream into Reality through HMG
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: URL Download to File

Post by Rathinagiri »

Thank you!. With this I have automated to download 1300+ files at a stretch! :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: URL Download to File

Post by serge_girard »

Hello,

How to compile in HMG ?

Serge
There's nothing you can do that can't be done...
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: URL Download to File

Post by bpd2000 »

serge_girard wrote: Wed Mar 07, 2018 12:38 pm Hello,

How to compile in HMG ?

Serge
.hbp file content
//---------
#harbour options:
-a
-m
-n
-v
-w3

#hbmk2 options:
-lurlmon


#sources:
Url_Down_Demo.prg
//---------
Are you facing any error ?
BPD
Convert Dream into Reality through HMG
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: URL Download to File

Post by serge_girard »

Hello,

I try to integrate in existing application. I get 'undefined reference to URLDownloadToF....'
My HBP file contains only PRG's and with -a -m... lots of errors

Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: URL Download to File

Post by serge_girard »

BPD,

OK now ! Thanks !

Serge
There's nothing you can do that can't be done...
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: URL Download to File

Post by apais »

PMFJI but..

what was it ?
Angel Pais
Web Apps consultant/architect/developer.
HW_apache (webserver modules) co-developer.
HbTron (Html GUI for harbour desktop hybrid apps) co-developer.
https://www.hbtron.com
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: URL Download to File

Post by serge_girard »

Don't know, just erased #harbour options !

Serge
There's nothing you can do that can't be done...
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: URL Download to File

Post by hmgchang »

Great.... But can i use it to download my hmgforum unread( 6905) and save each topics to seperate folder ?

TIA
Chang
Just Hmg It !
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: URL Download to File

Post by andyglezl »

Gracias bpd200 y KDJ !!!

Y tambien a todos los involucrados con sus comentario y dudas
porque de ahí resulta que se aclare, se aprenda, se modifique para cada necesidad...
-----------------------------------------------------------------------------------------------------------
Thanks bpd200 and KDJ !!!

And also to all those involved with their comments and doubts
because it results in clarification, learning, modification for every need ...


Aquí el mismo ejemplo modificado
------------------------------------------
Here the same modified example


Code: Select all

/*
From bpd2000
Expert help from KDJ
*/


#include "hmg.ch"

function Main()

   local Down_Result, cURL
   FOR i1 = 1 to 10	// Download All Files post from 1 to 10
      cNumPost := ALLTRIM( STR( i1, 6 ) )
      cURL := "http://www.hmgforum.com/download/file.php?id="+cNumPost
      Down_Result := DOWNLOADFILE( cURL, HB_CWD() + "HMGPOST_"+cNumPost+".ZIP" )
                         //file will be downloaded in current directory

      If Down_Result = 0 
         MsgStop ( "File " + cURL + hb_osnewline() + "has been downloaded!")
      Else 
         MsgStop ("File not found!")
      EndIf 
   NEXT

RETURN NIL
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply