请教高手,为什么openurl 第三次就弹出无法解析地址的异常
CString temp="username="+username+"&password="+pass;
CString strHttpName=httpname+temp;
CString isfullstr="";
CInternetSession* sess=new CInternetSession();
CHttpFile* fileGet=NULL;
CString strFormData = temp;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头
try
{
fileGet=(CHttpFile*)sess->OpenURL(strHttpName);//打开文件
}
catch(CException* e)
{
fileGet = 0;
throw;
}
CString strSentence, strGetSentence = "";
if(fileGet)
{
DWORD dwStatus;
DWORD dwBuffLen = sizeof(dwStatus);
BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
if( bSuccess && dwStatus>= 200 &&dwStatus<300 )
{
BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
while(fileGet->ReadString(strSentence)) // 读取提交数据后的返回结果
{
strGetSentence = strGetSentence + strSentence + char(13) + char(10);
}
//AfxMessageBox(strGetSentence); // 显示返回网页内容
}
else
{
strSentence.Format("POST出错,错误码:%d", dwStatus);
AfxMessageBox(strSentence);
}
fileGet->Close();
delete fileGet;
}
else
AfxMessageBox("不能找到网页文件!");
sess->Close();
return TRUE;
上面这个函数,调用第三次后,就弹出无法解析服务器地址的异常。但是strHttpName,调试看一直是一样的。这是为什么?