此成员函数调用构造 CHttpConnection 对象。
CHttpConnection(
CInternetSession* pSession,
HINTERNET hConnected,
LPCTSTR pstrServer,
DWORD_PTR dwContext
);
CHttpConnection(
CInternetSession* pSession,
LPCTSTR pstrServer,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
LPCTSTR pstrUserName = NULL,
LPCTSTR pstrPassword = NULL,
DWORD_PTR dwContext = 1
);
CHttpConnection(
CInternetSession* pSession,
LPCTSTR pstrServer,
DWORD dwFlags,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
LPCTSTR pstrUserName = NULL,
LPCTSTR pstrPassword = NULL,
DWORD_PTR dwContext = 1
);
参数
pSession
为 CInternetSession 对象的指针。hConnected
对于Internet连接的句柄。pstrServer
对包含服务器名称的字符串的指针。dwContext
CInternetConnection 对象的上下文标识符。请参见 Remarks 有关 dwContext的更多信息。nPort
标识此连接的Internet的端口号。pstrUserName
为指定用户的名称登录的一个Null结尾的字符串的指针。如果 NULL,默认值是匿名的。pstrPassword
为指定密码用于登录的一个Null终止的字符串的指针。如果 pstrPassword 和 pstrUserName 是 NULL,默认的匿名密码是用户的电子邮件名。如果 pstrPassword 是 NULL (或为空字符串),但 pstrUserName 不是 NULL,使用一个空密码。下表描述 pstrUserName 和 pstrPassword四个可能的设置的行为:pstrUserName
pstrPassword
用户名发送到FTP服务器。
密码发送到FTP服务器。
NULL 或“
NULL 或“
“匿名”
用户的电子邮件名
非NULL 字符串
NULL 或“
pstrUserName
" "
NULL 非NULL 字符串
错误
错误
非NULL 字符串
非NULL 字符串
pstrUserName
pstrPassword
dwFlags
INTERNET_ FLAG_* 标志的任意组合。为 dwFlags 值的声明参见。CHttpConnection::OpenRequest 的 Remarks 节中的表。
备注
您从不直接创建 CHttpConnection。相反,通过调用 CInternetSession::GetHttpConnection创建一个对象。
要求
Header: afxinet.h