L_InetFtpConnect

#include "ltweb.h"

L_INT EXT_FUNCTION L_InetFtpConnect(pszServer, iPort, pszUserName, pszPassword, pFtp)

L_TCHAR L_FAR *pszServer;

/* host name of an Internet server */

L_INTiPort;

/* port on the server to connect to */

L_TCHAR L_FAR pszUserName;

/* name of the user */

L_TCHAR L_FAR *pszPassword;

/* password */

pHFTP pFtp;

/* pointer to a structure */

Establishes a connection with the specified server.

Parameter

Description

pszServer

Character string that contains the host name of an FTP server. This can be a URL, like www.leadtools.com, or it can contain the IP number of the site, in ASCII dotted-decimal format (for example, 11.0.1.45).

iPort

Number of the TCP/IP port on the server to connect to. These flags set only the port that will be used. Use the default port for FTP servers: INTERNET_DEFAULT_FTP_PORT (port 21).

pszUserName

Character string that contains the name of the user logging on. If this parameter is NULL, the function uses the default "anonymous".

pszPassword

Character string that contains the password to use when logging on. If both pszPassword and pszUsername are NULL, the function uses the default "anonymous".

pFtp

Pointer to a valid handle to the FTP connection.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTFIL
LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_InetFtpDisConnect

Topics:

FTP Functions: FTP Connections

 

How to Program with FTP Functions

Example

L_INT TransferMyFile(L_TCHAR L_FAR *pszSourceFileName, L_TCHAR L_FAR *pszDistFileName)
{
   HFTP hFtp;
   L_INT nRetCode = SUCCESS;
   L_INT iPort = 21; //Default ftp port
   L_TCHAR szRemoteDir[MAX_PATH];

   nRetCode = L_InetFtpConnect(TEXT("ftp.Leadtools.com"), iPort, TEXT("User1"), TEXT("MyPassword"), &hFtp);
   if(nRetCode!=SUCCESS)
      return FAILURE;
   L_InetFtpGetFile (hFtp, TEXT(" Image.bmp "), TEXT(" ftpimage.bmp "), TRUE, SENDAS_BINARY);

   L_InetFtpRenameFile (hFtp, TEXT(" ImageOldName.bmp "), TEXT(" ImageNewName.bmp "));
   L_InetFtpDeleteFile (hFtp, TEXT(" File1.txt"));
   L_InetFtpChangeDir (hFtp, TEXT(" MyRootDirName "));
   L_InetFtpCreateDir (hFtp, TEXT(" MyNewSubDirName1"));
   L_InetFtpCreateDir(hFtp, TEXT(" MyNewSubDirName2"));
   nRetCode = L_InetFtpSendFile (hFtp, pszSourceFileName, pszDistFileName, SENDAS_BINARY);
   if(nRetCode!=SUCCESS)
      return FAILURE;
   L_InetFtpDeleteDir (hFtp, TEXT(" MyNewSubDirName2"));
   L_InetFtpGetCurrentDir (hFtp, szRemoteDir, MAX_PATH);
   L_InetFtpDisConnect (hFtp);
   return SUCCESS;
}