CInternetSession::GetFtpConnection

CFtpConnection* GetFtpConnection( LPCTSTR pstrServer**, LPCTSTR** pstrUserName = NULL, LPCTSTR pstrPassword = NULL, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, BOOL bPassive = FALSE );
Throw ( CInternetException );

Return Value

A pointer to a CFtpConnection object. If the call fails, determine the cause of the failure by examining the thrown CInternetException object.

Parameters

pstrServer

A pointer to a string containing the FTP server name.

pstrUserName

Pointer to a null-terminated string that specifies the name of the user to log in. If NULL, the default is anonymous.

pstrPassword

A pointer to a null-terminated string that specifies the password to use to log in. If both pstrPassword and pstrUserName are NULL, the default anonymous password is the user's email name. If pstrPassword is NULL (or an empty string) but pstrUserName is not NULL, a blank password is used. The following table describes the behavior for the four possible settings of pstrUserName and pstrPassword:

pstrUserName pstrPassword Username sent to FTP server Password sent to FTP server
NULL or “ “ NULL or “ “ "anonymous" User's email name
Non-NULL String NULL or “ “ pstrUserName “ “
NULL Non-NULL String ERROR ERROR
Non-NULL String Non-NULL String pstrUserName pstrPassword

nPort

A number that identifies the TCP/IP port to use on the server.

bPassive

Specifies passive or active mode for this FTP session. If set to TRUE, it sets the Win32 API dwFlag to INTERNET_FLAG_PASSIVE.

Remarks

Call this member function to establish an FTP connection and get a pointer to a CFtpConnection object.

GetFtpConnection connects to an FTP server, and creates and returns a pointer to a CFTPConnection object. It does not perform any specific operation on the server. If you intend to read or write to files, for example, you must perform those operations as separate steps. See the classes CFtpConnection and CFtpFileFind for information about searching for files, opening files, and reading or writing to files. See the article in Visual C++ Programmer’s Guide for steps in performing common FTP connection tasks.

Example

See the example for CFtpFileFind.

CInternetSession OverviewClass MembersHierarchy Chart

See Also   CFtpConnectionCInternetSession::GetGopherConnection, CInternetSession::GetHttpConnection, CInternetSession::OpenURL