18,356
社区成员
发帖
与我相关
我的任务
分享
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, //请求服务器
strObject,NULL,1,
NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_RELOAD);
if(pFile == NULL) //如果请求失败的话
{
SetLastErrorMsg();
return CF_RET_NETERROR;
}
pFile -> AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pFile -> AddRequestHeaders("Accept: */*");
pFile -> SendRequest(NULL, 0, (LPTSTR)(LPCTSTR)strPostData, strPostData.GetLength()); //POST数据
BOOL bSuccess = pFile->QueryInfo( //查询POST操作是否成功
HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
&dwStatus, &dwBuffLen);
CInternetSession m_winet(NULL,1,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
CHttpConnection *pConnection;
CHttpFile *pFile;
pConnection = m_winet.GetHttpConnection("expert.csdn.net");
CString strHeaders, tempStr,str;
str="name=*******&pass=******&type=1";
//strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
pFile=pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
"/member/logon.asp");
pFile->AddRequestHeaders("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*");
pFile->AddRequestHeaders("User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
pFile->AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pFile->SendRequest(
NULL,0,
(LPVOID)(LPCTSTR)str, str.GetLength());