请问如何编程与iis服务器通信.. 即通过程序模拟浏览器访问iis服务器...框架是怎样的?谢谢//[最好c/c++环境] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http协议IE 访问头部:GET /1.asp?id=323432 HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*Accept-Language: zh-cnAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)Host: www.hch.comConnection: Keep-Alive. http://member.netease.com/~maqianli/vc/Document/D_142.htm 给你端和服务器通讯的代码CInternetSession INetSession; CHttpConnection* pHttpServer=NULL; CHttpFile* pHttpFile=NULL; try { INetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_CONTROL_SEND_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, 120*1000); pHttpServer= INetSession.GetHttpConnection(m_strServerIp); //IP地址 pHttpFile= pHttpServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, szServreName, NULL, 1, NULL, NULL, INTERNET_FLAG_DONT_CACHE); // TRACE(szServreName); SetDlgItemText(IDC_STATIC_MESSAGE,"向服务起提出发送请求....."); if (!pHttpFile->SendRequestEx(nFileLen)) { if (pHttpFile!=NULL) { pHttpFile->Close(); delete pHttpFile; } if ( pHttpServer!=NULL) { pHttpServer->Close(); delete pHttpServer; } INetSession.Close(); MessageBox("向服务器发送请求失败!","错误", MB_OK|MB_ICONERROR); INetSession.Close(); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"开始向服务器发送数据....."); pHttpFile->Write(szSend,nFileLen); //将读取到的数据发送出去 SetDlgItemText(IDC_STATIC_MESSAGE,"发送完毕,正在结束发送....."); if (!(pHttpFile->EndRequest())) { if (pHttpFile!=NULL) { pHttpFile->Close(); delete pHttpFile; } if ( pHttpServer!=NULL) { pHttpServer->Close(); delete pHttpServer; } INetSession.Close(); MessageBox("结束传送请求失败", "错误", MB_OK|MB_ICONERROR); INetSession.Close(); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"正在获取服务器返回信息....."); nFileLen= pHttpFile->Read(cReceive,sizeof(cReceive)); strcat(szRecv,cReceive); if (nFileLen==0) { if (pHttpFile!=NULL) delete pHttpFile; if ( pHttpServer!=NULL) delete pHttpServer; INetSession.Close(); MessageBox("服务器未返回信息!","错误信息",MB_OK|MB_ICONERROR); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"已获取服务器返回信息,正在处理....."); } 如何在外部程序中加入控件或图片?! 如何判断单实例程序已经运行(不是判断自身) 求救:帮忙看下一句代码含义! 在VC++6.0中怎么使用其它库如ACE error C2059: syntax error : 'bad suffix on number ODBC API如何取得结果集的记录个数? 怎样才能把 dest 的值赋给sz VC6好像不支持ADO啊?是不是? VC中处理FLASH动画的问题。 用cmake编译时报错,求解释 ■■■有人知道LPC线性预测编码算法■■■ 很简单的问题?
IE 访问头部:GET /1.asp?id=323432 HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)
Host: www.hch.com
Connection: Keep-Alive
.
CHttpConnection* pHttpServer=NULL;
CHttpFile* pHttpFile=NULL;
try
{
INetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_CONTROL_SEND_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, 120*1000);
pHttpServer= INetSession.GetHttpConnection(m_strServerIp); //IP地址
pHttpFile= pHttpServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,
szServreName,
NULL,
1,
NULL,
NULL,
INTERNET_FLAG_DONT_CACHE); // TRACE(szServreName); SetDlgItemText(IDC_STATIC_MESSAGE,"向服务起提出发送请求.....");
if (!pHttpFile->SendRequestEx(nFileLen))
{
if (pHttpFile!=NULL)
{
pHttpFile->Close();
delete pHttpFile;
}
if ( pHttpServer!=NULL)
{
pHttpServer->Close();
delete pHttpServer;
}
INetSession.Close();
MessageBox("向服务器发送请求失败!","错误", MB_OK|MB_ICONERROR);
INetSession.Close();
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"开始向服务器发送数据....."); pHttpFile->Write(szSend,nFileLen); //将读取到的数据发送出去
SetDlgItemText(IDC_STATIC_MESSAGE,"发送完毕,正在结束发送.....");
if (!(pHttpFile->EndRequest()))
{
if (pHttpFile!=NULL)
{
pHttpFile->Close();
delete pHttpFile;
}
if ( pHttpServer!=NULL)
{
pHttpServer->Close();
delete pHttpServer;
}
INetSession.Close();
MessageBox("结束传送请求失败", "错误", MB_OK|MB_ICONERROR);
INetSession.Close();
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"正在获取服务器返回信息.....");
nFileLen= pHttpFile->Read(cReceive,sizeof(cReceive)); strcat(szRecv,cReceive);
if (nFileLen==0)
{
if (pHttpFile!=NULL) delete pHttpFile;
if ( pHttpServer!=NULL) delete pHttpServer;
INetSession.Close();
MessageBox("服务器未返回信息!","错误信息",MB_OK|MB_ICONERROR);
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"已获取服务器返回信息,正在处理....."); }