URL Download to File
Posted: Sat Jun 17, 2017 9:33 am
Working example of URLdownloadto file
It finished after expert help from KDJ
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