18,356
社区成员
发帖
与我相关
我的任务
分享
CString strObject;
INTERNET_PORT nPort;
CString strFormData;
DWORD dwServiceType;
CInternetSession g_Session_HG("My Session");
CString strContent="";
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strURL="www.126.com";
CString strRetMsg;
strFormData="user=yuecaipeng&password=861124&style=-1&remUser=checked&username=yuecaipeng@126.com";
CString strServer="";
if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
return ;
}
pServer = g_Session_HG.GetHttpConnection(strURL,nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject);//NULL,1,NULL,NULL,
// pFile->AddRequestHeaders("Content-Type:text/html; charset=gb2312");
BOOL result = pFile->SendRequest(NULL,0,
(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if (dwRet != HTTP_STATUS_OK)
{
return ;
}
CString cookie;
pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie);
if( cookie!="" )
g_Session_HG.SetCookie(strURL,"",cookie);