18,356
社区成员
发帖
与我相关
我的任务
分享
CString strObject;
INTERNET_PORT nPort;
CString strFormData;
CString strServer;
DWORD dwServiceType;
CInternetSession g_Session_HG("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strURL="http://www.126.com";
CString strRetMsg;
strFormData=_T("user=yindoor123&password=123456&style=-1&remUser=checked&secure=checked");
CString strHeader=_T("Content-Type:text/html; charset=gb2312\r\n");
if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
MessageBox(_T("不是HTTP站点"),_T("错误"));
return ;
}
pServer = g_Session_HG.GetHttpConnection(strServer,nPort);
strObject=_T("logins.jsp");
pFile = pServer->OpenRequest("POST",strObject);
pFile->SendRequest(strHeader,(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
CString str;
CString a;
while(pFile->ReadString(a))
{
str+=a;
str+="\r\n";
}
SetDlgItemText(IDC_EDIT1,str);
pFile->
delete pFile;
delete pServer;