URL Download to File

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

Moderator: Rathinagiri

Post Reply
User avatar
bpd2000
Posts: 1005
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 154 times
Been thanked: 66 times

URL Download to File

Post by bpd2000 » Sat Jun 17, 2017 9:33 am

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

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

Post by Rathinagiri » Wed Jun 28, 2017 2:48 pm

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

Post by serge_girard » Wed Mar 07, 2018 12:38 pm

Hello,

How to compile in HMG ?

Serge

User avatar
bpd2000
Posts: 1005
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 154 times
Been thanked: 66 times

Post by bpd2000 » Wed Mar 07, 2018 1:08 pm

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

Post by serge_girard » Wed Mar 07, 2018 1:57 pm

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

Post by serge_girard » Wed Mar 07, 2018 3:09 pm

BPD,

OK now ! Thanks !

Serge

User avatar
apais
Posts: 273
Joined: Fri Aug 01, 2008 6:03 pm
Location: uruguay
Has thanked: 33 times
Been thanked: 21 times
Contact:

Post by apais » Wed Mar 07, 2018 6:47 pm

PMFJI but..

what was it ?

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

Post by serge_girard » Wed Mar 07, 2018 8:27 pm

Don't know, just erased #harbour options !

Serge

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

Post by hmgchang » Thu Mar 08, 2018 6:13 am

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

Post by andyglezl » Fri Mar 09, 2018 6:06 pm

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