Re: How to use FTP functions

From: Paul G. Tobey [eMVP] (ptobey)
Date: 11/04/04


Date: Thu, 4 Nov 2004 09:16:08 -0700

I've stripped the error checking from the code below, but it retrieves a
file from an FTP server.

 // Create internet connection.
 HINTERNET h = InternetOpen( _T( "FTPTest" ), INTERNET_OPEN_TYPE_PRECONFIG,
     NULL, NULL, 0 );

 // Connect to FTP server.
 // Set user name and password to NULL to use anonymous login.
 TCHAR *user = _T( "anonymous" );
 TCHAR *password = _T( "none@none.com" );
 HINTERNET c = InternetConnect( h, _T( "172.16.12.1" ),
     INTERNET_DEFAULT_FTP_PORT,
     user, password, INTERNET_SERVICE_FTP, 0, 0 );

 // Remove any existing target file from the file system.
 TCHAR *targetName = _T( "\\nk.bin" );

 if ( !FtpGetFile( c, _T( "nk.bin" ), targetName,
  FALSE, 0, FTP_TRANSFER_TYPE_BINARY, 0 ) )

Paul T.

"kamaal" <kamaalwince@rediffmail.com> wrote in message
news:dd2f4359.0411040018.5b96df72@posting.google.com...
> Hi all,
>
> I want to implement ftp file transfers from host m/c to the target
> board using a program.The target board is the ftp client and the host
> m/c is the ftp server.
> I have to use the functions InternetOpen() and InternetConnect() as
> follows:
>
> HINTERNET InternetOpen(
> LPCTSTR lpszAgent,
> DWORD dwAccessType,
> LPCTSTR lpszProxyName,
> LPCTSTR lpszProxyBypass,
> DWORD dwFlags
> );
>
> Here, what is the first argument " LPCTSTR lpszAgent" of this
> function?If I want to invoke ftp transfer,what should this argument
> be?I'm using this function as follows:
>
> hInternet=InternetOpen(TEXT("ftpclient"),INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
>
> if(hInternet==NULL)
>
> RETAILMSG(1,(TEXT("InternetOpen failure %d\n"),GetLastError()));
> else
> {
>
> if(!(ftpHandle=InternetConnect(hInternet,L"ftp://xxx.xxx.yy.yy",INTERNET_DEFAULT_FTP_PORT,NULL,NULL,INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0)))
>
>
> RETAILMSG(1,(TEXT("InternetConnect failure %d\n"),GetLastError()));
>
> }
>
> But I'm getting error code 12029 in the function InternetConnect().
>
> What's wrong?I'm specifying proper host IP address."ftpclient" is the
> name of my application program.
>
> Kindly help me.
>
> Regards,
> Kamaal



Relevant Pages

  • Re: [ OT ] WinInet API: Accessing a file on FTP for Reading
    ... |I am using WinInet APIs to access a file on an FTP server (using ... | InternetOpen, InternetConnect, FtpOpenFile). ... | a better alternative (like the one provided by CreateFile windows API ...
    (alt.comp.lang.learn.c-cpp)
  • WinInet API: Accessing a file on FTP for Reading
    ... I am using WinInet APIs to access a file on an FTP server (using ... InternetOpen, InternetConnect, FtpOpenFile). ... Before downloading, I ...
    (microsoft.public.win32.programmer.networks)
  • WinInet API: Accessing a file on FTP for Reading
    ... I am using WinInet APIs to access a file on an FTP server (using ... InternetOpen, InternetConnect, FtpOpenFile). ... Before downloading, I ...
    (alt.comp.lang.learn.c-cpp)
  • ftputil - uploading many files too long
    ... py_file target = target_open ... I think its not about many files but because of it takes too long for my ftp server. ... geon. ...
    (comp.lang.python)
  • FTP Server
    ... I can not get the FTP server to work. ... The target is Win CE ... Development system is Win XP pro. ...
    (microsoft.public.windowsce.embedded)

Loading