CHttpFile网络交互功能实现...

程序内部读取网络信息, 该代码可以通过网络提交验证密码再进行判断...

首先,需要在文件头加上 #include <afxinet.h>

CInternetSession mySession(NULL,0);
CHttpFile* myHttpFile=NULL;

CString myData;
CString myUrl;
myUrl = "http://127.0.0.1/yanz.php?name=" + m_myName + "&password=" + m_myPassword;
myHttpFile=(CHttpFile*)mySession.OpenURL(myUrl);
while(myHttpFile->ReadString(myData))
{
m_SiteInfo = myData;
}

if( m_SiteInfo == "hao" ){
CDialog::OnCancel();
}else{
AfxMessageBox( "密码错误", NULL, MB_OK );
}

myHttpFile->Close();
mySession.Close();

-----------------------------------------------

CHttpFile Class Members

Construction

CHttpFileCreates a CHttpFile object.

Operations

AddRequestHeadersAdds headers to the request sent to an HTTP server.
SendRequestSends a request to an HTTP server.
SendRequestExSends a request to an HTTP server using the Write or WriteString methods of CInternetFile.
EndRequestEnds a request sent to an HTTP server with the SendRequestEx member function.
QueryInfoReturns the response or request headers from the HTTP server.
QueryInfoStatusCodeRetrieves the status code associated with an HTTP request and places it in the supplied dwStatusCode parameter.
GetVerbGets the verb that was used in a request to an HTTP server.
GetObjectGets the target object of the verb in a request to an HTTP server.
GetFileURLGets the URL for the specified file.
CloseCloses the CHttpFile and frees its resources.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值