Re: Function to download a defined file from a homepage ?
Posted: Fri Apr 22, 2016 7:01 pm
www.FiveTechSoft.com
https://fivetechsupport.com/forums/
Code: Select all | Expand
via ftp : ok perfect ,,,
// Wininet constants
#define INTERNET_OPEN_TYPE_PRECONFIG 0
#define INTERNET_OPEN_TYPE_DIRECT 1
#define INTERNET_OPEN_TYPE_PROXY 3
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4
#define INTERNET_INVALID_PORT_NUMBER 0
#define INTERNET_DEFAULT_FTP_PORT 21
#define INTERNET_DEFAULT_GOPHER_PORT 70
#define INTERNET_DEFAULT_HTTP_PORT 80
#define INTERNET_DEFAULT_HTTPS_PORT 443
#define INTERNET_DEFAULT_SOCKS_PORT 1080
#define INTERNET_SERVICE_FTP 1
#define INTERNET_SERVICE_GOPHER 2
#define INTERNET_SERVICE_HTTP 3
#define INTERNET_FLAG_TRANSFER_ASCII 1
#define INTERNET_FLAG_TRANSFER_BINARY 2
#define MODE 2
#define INTERNET_FLAG_ACTIVE 0
#define INTERNET_FLAG_PASSIVE 134217728
#define FILE_ATTRIBUTE_ARCHIVE 128
// FTPGETFILE( hConnect, cRemotePath + "/" + alltrim( cFileName ),"c:\temp\autoexec.bat", 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0 )
//**********************************************************************
FUNCTION FTPWRITEFILE( cServerName, cLocalPath, cRemotePath, cUserName, cPassword, cFileName )
LOCAL hInternet, hConnect
LOCAL lOk
IF !FILE(cLocalPath + alltrim(cFileName))
MYMEN("Error. Archivo no existe : "+cLocalPath + alltrim(cFileName))
RETURN .F.
ENDIF
hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
hConnect = INTERNETCONNECT( hInternet, cServerName, INTERNET_DEFAULT_FTP_PORT, cUserName, cPassword, INTERNET_SERVICE_FTP, MODE, 0 )
lOk = FTPPUTFILE( hConnect, cLocalPath + alltrim(cFileName), cRemotePath + alltrim( cFileName ), 0, 0 )
IF lOk
msgwait(hb_oemtoansi("La transferencia v¡a FTP, fue exitosa"),"Aviso informativo",10 )
ELSE
msgwait(hb_oemtoansi("La transferencia v¡a FTP, fue fallida"),"Aviso informativo",10 )
ENDIF
INTERNETCLOSEHANDLE( hConnect )
INTERNETCLOSEHANDLE( hInternet )
RETURN lOk
//***************************************************************
#pragma BEGINDUMP
#include "windows.h"
#include "wininet.h"
#include "hbapi.h"
HB_FUNC( INTERNETOPEN )
{
hb_retnl( ( LONG ) InternetOpen( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ), hb_parnl( 5 ) ) );
}
HB_FUNC( INTERNETCLOSEHANDLE )
{
hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}
HB_FUNC( INTERNETCONNECT )
{
hb_retnl( ( LONG ) InternetConnect( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), ( INTERNET_PORT ) hb_parnl( 3 ), hb_parc( 4 ), hb_parc( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) ) );
}
HB_FUNC( FTPPUTFILE )
{
hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}
HB_FUNC( FTPGETFILE )
{
hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );
}
#pragma ENDDUMP
//*******************************************************
Code: Select all | Expand
TEST.EXE : TEST.obj
C:\BORLAND\BCC55\bin\ilink32 -Gn -aa -Tpe -s -LC:\BORLAND\BCC55\lib @TEST.bc
TEST.c : TEST.prg
C:\HARBOUR\BIN\HARBOUR TEST /n /w /p /IC:\HARBOUR\INCLUDE;C:\FWH\INCLUDE /DNORMAL
TEST.obj : TEST.c
C:\BORLAND\BCC55\BIN\BCC32 -M -c /IC:\HARBOUR\INCLUDE;C:\BORLAND\BCC55\INCLUDE;C:\FWH\INCLUDE TEST.c
Code: Select all | Expand
C:\BORLAND\BCC55\lib\c0w32.obj +
TEST.obj, +
TEST.EXE, +
TEST.MAP, +
C:\FWH\lib\FiveH.lib +
C:\FWH\lib\FiveHC.lib +
c:\harbour\lib\rtl.lib +
c:\harbour\lib\vm.lib +
c:\harbour\lib\gtgui.lib +
c:\harbour\lib\lang.lib +
c:\harbour\lib\macro.lib +
c:\harbour\lib\rdd.lib +
c:\harbour\lib\dbfntx.lib +
c:\harbour\lib\dbfcdx.lib +
c:\harbour\lib\dbffpt.lib +
c:\harbour\lib\hbsix.lib +
c:\harbour\lib\debug.lib +
c:\harbour\lib\common.lib +
c:\harbour\lib\codepage.lib +
c:\borland\bcc55\lib\cw32.lib +
c:\borland\bcc55\lib\import32.lib +
c:\borland\bcc55\lib\psdk\odbc32.lib +
c:\borland\bcc55\lib\psdk\nddeapi.lib +
c:\borland\bcc55\lib\psdk\iphlpapi.lib +
c:\borland\bcc55\lib\psdk\rasapi32.lib +
c:\borland\bcc55\lib\psdk\urlmon.lib +
c:\borland\bcc55\lib\inet.lib
Code: Select all | Expand
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
echo -c -tWM -D__HARBOUR__ -DHB_API_MACROS > tmp
echo -Ic:\develop\harbour\include;c:\develop\fwh\include >> tmp
c:\develop\borland\bcc55\bin\bcc32 -oobj\TestDownload @tmp TestDownload.
c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
TestDownload.c:
Error E2238 c:\develop\harbour\include\clipdefs.h 80: Multiple declaration for ' WORD'
Error E2344 c:\Develop\Borland\Bcc55\include\windef.h 145: Earlier declaration of 'WORD'
Error E2238 c:\develop\harbour\include\clipdefs.h 82: Multiple declaration for ' PWORD'
Error E2344 c:\Develop\Borland\Bcc55\include\windef.h 154: Earlier declaration of 'PWORD'
Error E2238 c:\develop\harbour\include\clipdefs.h 102: Multiple declaration for 'BOOL'
Error E2344 c:\Develop\Borland\Bcc55\include\windef.h 143: Earlier declaration of 'BOOL'
Error E2238 c:\develop\harbour\include\clipdefs.h 105: Multiple declaration for 'PBOOL'
Error E2344 c:\Develop\Borland\Bcc55\include\windef.h 148: Earlier declaration of 'PBOOL'
Error E2238 c:\develop\harbour\include\clipdefs.h 114: Multiple declaration for 'HANDLE'
Error E2344 c:\Develop\Borland\Bcc55\include\winnt.h 283: Earlier declaration of 'HANDLE'
*** 10 errors in Compile ***
Code: Select all | Expand
#include "fivewin.ch"
function Main()
LOCAL nRet
nRet := DOWNLOADFILE( "http://www.yoursite.it/index.html", "C:\index.html" )
MsgStop( nRet )
RETURN NIL
#pragma BEGINDUMP
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#include <urlmon.h>
HB_FUNC( DOWNLOADFILE )
{
unsigned long lRet ;
lRet = URLDownloadToFile( NULL, _parc( 1 ), _parc( 2 ), 0, NULL ) ;
_retnl( lRet ) ;
}
#pragma ENDDUMP
Code: Select all | Expand
#include "fivewin.ch"
function Main()
LOCAL nRet
nRet := DOWNLOADFILE( "http://www.yoursite.it/index.html", "C:\index.html" )
MsgStop( nRet )
RETURN NIL
#pragma BEGINDUMP
#define _CLIPDEFS_H
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#include <urlmon.h>
HB_FUNC( DOWNLOADFILE )
{
unsigned long lRet ;
lRet = URLDownloadToFile( NULL, _parc( 1 ), _parc( 2 ), 0, NULL ) ;
_retnl( lRet ) ;
}
#pragma ENDDUMP
Code: Select all | Expand
#include "fivewin.ch"
function Main()
LOCAL nRet
nRet := DOWNLOADFILE( "http://www.yoursite.it/index.html", "C:\index.html" )
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