Dll发送http请求
大宝 2009-01-14 03:35:56 我写了一个dll,用途是发送http请求,得到一个返回结果,可是我用一程序调用时出现错误窗口:
Debug Assertion Failed!
Program:E:\.....*.exe
File:afxwin1.inl
Line:27
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
点击忽略按钮,程序也能执行完毕。
后来调试发现因为dll里用到 CInternetSession sess; 只要有就会出现以上情况,有没有高手指点下怎么解决呢???
源码如下:
CInternetSession sess(NULL,0);//建立会话 如果不用 我怎么发送http请求???
CHttpFile *fileGet=NULL;
CString Text;
CString Texttmp="";
CString strHttpName = "http://localhost:8080/posserver/query/query.do";
CException *e;
TRY
{
fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//打开文件
if (fileGet == NULL)
{
return FALSE; //读取失败返回
}
while (fileGet->ReadString(Text))
{
Texttmp = Texttmp+"\r\n";
Texttmp+=Text;
}
// 将字符串写入xml文件中
// FILE *fp=fopen("filename.xml","w");
// fwrite(Texttmp,Texttmp.GetLength(),1,fp);
// fclose(fp);
}
CATCH_ALL(e)
{
return GetLastError();
fileGet = 0;
}
sess.Close();
END_CATCH_ALL