CHttpConnection* 类中声明问题。高手进啊~~~
-------------------Http.h文件----------------------------
#include "stdafx.h"
#include <afxinet.h>
#include <atlimage.h>
class Http
{
public:
CHttpConnection* h_con;
void Get(CString in_url,CString in_referer="",CString in_cookie="");
};
------------------Http.cpp文件--------------------------------
void Http::Get(CString in_url,CString in_referer,CString in_cookie)
{
//转换网址
CString domain,url_hz;
DWORD url_type;
unsigned short port;
CString tmp;
AfxParseURL(in_url,url_type,domain,url_hz,port);
CInternetSession pt;
CHttpFile* f_pt;
this->h_con=pt.GetHttpConnection(domain,port);
f_pt=this->h_con->OpenRequest(CHttpConnection::HTTP_VERB_GET,url_hz,0,1,0,0,INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_NO_AUTO_REDIRECT);
this->Set_header(f_pt,domain,in_referer,in_cookie,"");
f_pt->SendRequest();
//获取返回数据
tmp.Empty();
this->out_data.Empty();
while(f_pt->ReadString(tmp))
{
this->out_data+=tmp+"\r\n";
//tmp.Empty();
}
}
执行到f_pt=this->h_con->OpenRequest(CHttpConnection::HTTP_VERB_GET,url_hz,0,1,0,0,INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_NO_AUTO_REDIRECT);
出现无效指针。这么才能解决。