URL Download to File

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

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1144
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 243 times
Been thanked: 139 times

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 376 times
BPD
Convert Dream into Reality through HMG

User avatar
Rathinagiri
Posts: 5298
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 183 times
Been thanked: 201 times
Contact:

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: 2506
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 799 times
Been thanked: 153 times
Contact:

Post by serge_girard »

Hello,

How to compile in HMG ?

Serge

User avatar
bpd2000
Posts: 1144
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 243 times
Been thanked: 139 times

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: 2506
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 799 times
Been thanked: 153 times
Contact:

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

User avatar
serge_girard
Posts: 2506
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 799 times
Been thanked: 153 times
Contact:

Post by serge_girard »

BPD,

OK now ! Thanks !

Serge

User avatar
apais
Posts: 335
Joined: Fri Aug 01, 2008 6:03 pm
Location: uruguay
Has thanked: 59 times
Been thanked: 36 times
Contact:

Post by apais »

PMFJI but..

what was it ?

User avatar
serge_girard
Posts: 2506
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 799 times
Been thanked: 153 times
Contact:

Post by serge_girard »

Don't know, just erased #harbour options !

Serge

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

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: 1248
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 38 times
Been thanked: 107 times
Contact:

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