有实例么
特别是和Servlet通信的部分
分值不够可追加
特别是和Servlet通信的部分
分值不够可追加
解决方案 »
- 图片小问题
- 请高手找错!None of the functions with this name in scope match the target type
- 怎样在VC中生成DLL,然后这个DLL可以供delphi
- 怎样获取本机目录信息
- ListControl的使用方法!!
- 请问如何通过ip查找相应的机器名?
- 释放线程资源的问题
- 如何在2000/NT下调用BIOS中断?
- 新版简直是垃圾! 强烈建议大家发EMAIL给版主要求改回原版 !!
- 程序员薪水、待遇调查
- 我要把一个unicode字符转成2个16进制的字符存到一个字符数组里,怎么转换啊,或者说vc里有什么函数可以作到的?
- 视图指针问题,高手帮忙!谢谢!
一般情况下,请求是由Web浏览器产生的,但其他客户机如Java应用客户机和VC客户机也可以产生请求信息。
那位大侠了解其工作方法吗
最好有实例配合
BOOL GetInternetFile (LPTSTR lpszServer)
{
//Example: Now let's see how to use all these functions in our example.
//This example shows how to download contents of a page using HTTP API functions.
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ; hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); if ( !hINet )
{
AfxMessageBox("InternetOpen Failed");
return;
} try
{
hConnection = InternetConnect( hINet, "www.mindcracker.com", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
return;
}
// Get data
hData = HttpOpenRequest( hConnection, "GET", "/uicsa/index.htm", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 ); if ( !hData )
{
InternetCloseHandle(hConnection);
InternetCloseHandle(hINet);
return;
}
HttpSendRequest( hData, NULL, 0, NULL, 0);
while( InternetReadFile( hData, buffer, 255, &dwRead ) )
{
if ( dwRead == 0 )
return;
buffer[dwRead] = 0;
m_strContents += buffer;
} }
catch( CInternetException* e)
{
e->ReportError();
e->Delete();
}
InternetCloseHandle(hConnection);
InternetCloseHandle(hINet);
InternetCloseHandle(hData);
return bReturn;
}
{
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString ServerName = "webmail.21cn.com";
INTERNET_PORT nPort = 80;
DWORD retcode;
char outBuff[300] = "LoginName=aaa&passwd=xxx&DomainName=21cn.com";//I have test this with my loginname and password
try
{
pServer = session.GetHttpConnection(ServerName,nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/NULL/NULL/NULL/NULL/NULL/SignIn.gen",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
pFile -> AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pFile -> AddRequestHeaders("Accept: */*");
pFile -> SendRequest(NULL,0,outBuff,strlen(outBuff)+1);
pFile -> QueryInfoStatusCode(retcode);
// you can read from the file after this......I've just left it out.
for(int i=0;i<10;i++)//read ten line of returned HTML,you need to edit this to use the result
{
CString smsg;
pFile->ReadString(smsg);
AfxMessageBox(smsg);
}
DWORD dwlen=pFile->GetLength();
char buf[1024];
DWORD dwread=pFile->Read(buf,1024);
}
catch (CInternetException * e){};
delete pFile;
delete pServer;
session.Close();
}
这里面的参数是怎么确定的?
有多大关系?不吝赐教
必须采用模仿java applet的方式