CFtpConnection::CFtpConnection

此成员函数调用构造 CFtpConnection 对象。

CFtpConnection(
   CInternetSession* pSession,
   HINTERNET hConnected,
   LPCTSTR pstrServer,
   DWORD_PTR dwContext
);
CFtpConnection(
   CInternetSession* pSession,
   LPCTSTR pstrServer,
   LPCTSTR pstrUserName = NULL,
   LPCTSTR pstrPassword = NULL,
   DWORD_PTR dwContext = 0,
   INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
   BOOL bPassive = FALSE
);

参数

  • pSession
    对相关 CInternetSession 对象的指针。

  • hConnected
    当前Internet会话的Windows句柄。

  • pstrServer
    对包含FTP服务器名称的字符串的指针。

  • dwContext
    操作的上下文标识符。 dwContext 标识 CInternetSession::OnStatusCallback返回的操作的状态信息。 该默认设置为1;但是,可以为操作显式分配特定上下文ID。 它的对象及其所有工作要与该上下文ID.

  • pstrUserName
    为指定用户的名称登录的一个Null结尾的字符串的指针。 如果 NULL,默认值是匿名的。

  • pstrPassword
    为指定密码用于登录的一个Null终止的字符串的指针。 如果 pstrPassword 和 pstrUserName 是 NULL,默认的匿名密码是用户的电子邮件名。 如果 pstrPassword 是 NULL (或为空字符串),但 pstrUserName 不是 NULL,使用一个空密码。 下表描述 pstrUserName 和 pstrPassword四个可能的设置的行为:

    pstrUserName

    pstrPassword

    用户名发送到FTP服务器。

    密码发送到FTP服务器。

    NULL 或“

    NULL 或“

    “匿名”

    用户的电子邮件名

    NULL 字符串

    NULL 或“

    pstrUserName

    " "

    NULLNULL 字符串

    错误

    错误

     

    NULL 字符串

    NULL 字符串

    pstrUserName

    pstrPassword

  • nPort
    在服务器标识TCP/IP端口的数字。

  • bPassive
    为此FTP会话指定被动或活动模式。 如果设置为 TRUE,它将Win32 API dwFlag 到 INTERNET_FLAG_PASSIVE

备注

您从不直接创建一 CFtpConnection 对象。 相反,请调用 CInternetSession::GetFtpConnection,创建 CFptConnection 对象。

要求

Header: afxinet.h

请参见

参考

CFtpConnection选件类

层次结构图

CInternetSession::GetFtpConnection

CFtpFileFind选件类

CGopherConnection选件类

CHttpConnection选件类

CInternetConnection选件类