FTP with Harbour / MSVC / FWH issues

FTP with Harbour / MSVC / FWH issues

Postby TimStone » Tue Jun 19, 2018 11:56 pm

I am running a program built with xHarbour / FWH that must do FTP processes. It works perfectly. I am using the .dll WININET and calling the functions:
INTERNETOPEN
INETCLOSEHANDLE
FTPGETFILE
FTPPUTFILE
INTERNETCONNECT

However, when I build using Harbour / MSVC / FWH, it appears to not recognize the WININET.dll because it gives me unidentified externals when trying to do run a successful build

These are all redefined as follows:
Code: Select all  Expand view


DLL32 FUNCTION InternetOpen( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags ;
    AS DWORD ) AS LONG PASCAL FROM "InternetOpenA" LIB iDLL

DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
    PASCAL FROM "InternetCloseHandle" LIB iDLL

DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, ;
    nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpGetFileA" LIB iDLL

DLL32 FUNCTION FtpPutFile( hFTP AS LONG, cFileName AS LPSTR, cDestFile AS LPSTR,;
    n1 AS LONG, n2 AS LONG ) AS BOOL PASCAL ;
    FROM "FtpPutFileA" LIB iDLL

DLL32 FUNCTION InternetConnect( hSession AS LONG, cHost AS LPSTR, nPort AS LONG,;
    cUserName AS LPSTR, cPassword AS LPSTR, n4 AS LONG, n5 AS LONG,;
    n6 AS LONG ) AS LONG PASCAL ;
    FROM "InternetConnectA" LIB iDLL
 


iDLL is defined:
PRIVATE iDLL := LoadLibrary( "wininet.dll" )

As I said, this code is fine with xHarbour, but not Harbour. I've tried other approaches but all are problematic. Any ideas on this one ?
Last edited by TimStone on Thu Jun 21, 2018 6:20 pm, edited 1 time in total.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FTP with Harbour / MSVC / FWH issues

Postby Enrico Maria Giordano » Thu Jun 21, 2018 11:44 am

Please, check your message and fix it. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP with Harbour / MSVC / FWH issues

Postby TimStone » Thu Jun 21, 2018 6:21 pm

Took out the spurious part ..l
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FTP with Harbour / MSVC / FWH issues

Postby Enrico Maria Giordano » Thu Jun 21, 2018 6:49 pm

The following sample compiles and links fine here (of course it doesn't run):

Code: Select all  Expand view
#include "Fivewin.ch"


STATIC iDLL


FUNCTION MAIN()

    INTERNETOPEN()
    INTERNETCLOSEHANDLE()
    FTPGETFILE()
    FTPPUTFILE()
    INTERNETCONNECT()

    RETURN NIL


DLL32 FUNCTION InternetOpen( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags ;
    AS DWORD ) AS LONG PASCAL FROM "InternetOpenA" LIB iDLL

DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
    PASCAL FROM "InternetCloseHandle" LIB iDLL

DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, ;
    nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpGetFileA" LIB iDLL

DLL32 FUNCTION FtpPutFile( hFTP AS LONG, cFileName AS LPSTR, cDestFile AS LPSTR,;
    n1 AS LONG, n2 AS LONG ) AS BOOL PASCAL ;
    FROM "FtpPutFileA" LIB iDLL

DLL32 FUNCTION InternetConnect( hSession AS LONG, cHost AS LPSTR, nPort AS LONG,;
    cUserName AS LPSTR, cPassword AS LPSTR, n4 AS LONG, n5 AS LONG,;
    n6 AS LONG ) AS LONG PASCAL ;
    FROM "InternetConnectA" LIB iDLL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP with Harbour / MSVC / FWH issues

Postby TimStone » Thu Jun 21, 2018 11:29 pm

Yes, it compiles and links fine ... but then when I run it, it can't find the function. Therein lies the problem.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FTP with Harbour / MSVC / FWH issues

Postby Enrico Maria Giordano » Fri Jun 22, 2018 8:03 am

Please, provide a reduced and self-contained sample of the problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP with Harbour / MSVC / FWH issues

Postby russimicro » Fri Jun 22, 2018 9:17 pm

xharbour.com + fivewin

Code: Select all  Expand view



// 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


//**********************************************************************

FUNCTION FTPWRITEFILE( cServerName, cLocalPath, cRemotePath, cUserName, cPassword, cFileName, sinEspera )

    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 sinEspera == NIL

       IF lOk
          msgwait(hb_oemtoansi("La transferencia v¡a FTP, fue exitosa"),"Aviso informativo",5 )
       ELSE
          msgwait(hb_oemtoansi("La transferencia v¡a FTP, fue fallida"),"Aviso informativo",5 )
       ENDIF
    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


//*******************************************************


 
russimicro
 
Posts: 255
Joined: Sun Jan 31, 2010 3:30 pm
Location: Bucaramanga - Colombia

Re: FTP with Harbour / MSVC / FWH issues

Postby TimStone » Mon Jun 25, 2018 5:23 pm

I have it functioning with xHabour. I want to use Harbour + MSVC + FWH.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FTP with Harbour / MSVC / FWH issues

Postby ShumingWang » Wed Jun 27, 2018 8:22 am

Another , how use ftp over TLS ?

hLib = LOADLIBRARY( "wininet.dll" )

hInternet := INETOPEN( "Anystring", 1, 0, 0, 0 )

hConnect := INETCONNECT( hInternet, "www.xtech.com.cn",21, "xxx@xtech.com.cn", "erp6.5", 1, 0,0 )

if !EMPTY( hInternet ).and.!EMPTY( hConnect )
msgmeter({|ometer,otext,odlg,lend|download002(ometer,otext,odlg,@lend,hConnect)},"正在下载,可能需要几分钟...","下载提示")
msginfo("已经升级完毕","提示")
else
msginfo("网络不通,下载失败","提示")
// remote, local file
end
INETCLOSEHANDLE( hConnect )
INETCLOSEHANDLE( hInternet )
FREELIBRARY( hLib )

return nil

FUNCTION download002(ometer,otext,odlg,lend,hConnect)
local n1:=0

ometer:SetTotal(3)
ometer:set(++n1)
FTPGETFILE( hConnect, "xerp.exe", "xerp.exe", 0,32, 0, 0 )
ometer:set(++n1)
FTPGETFILE( hConnect, "xerp.dll", "xerp.dll", 0,32, 0, 0 )
ometer:set(++n1)
return .t.

DLL32 FUNCTION INETOPEN( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags AS DWORD ) AS LONG;
PASCAL FROM "InternetOpenA" LIB hLib

DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
PASCAL FROM "InternetCloseHandle" LIB hLib

DLL32 FUNCTION INETCONNECT( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG;
PASCAL FROM "InternetConnectA" LIB hLib

DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpGetFileA" LIB hLib

DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpPutFileA" LIB hLib
Thanks !
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests