一调用HttpOpenRequest就跳出一个诊断宏,急死我了

IceKettle 2006-06-08 04:17:47
我用Visual C++ 2005开发一个Outlook插件,其中需要下载文件。
我是这样作的:
//Create the Internet session handle
m_hInternetSession = ::InternetOpen(m_msgUi._szTitle, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (m_hInternetSession == NULL)
{
HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_GENERIC_ERROR);
return;
}

//Setup the status callback function
if (::InternetSetStatusCallback(m_hInternetSession, _OnStatusCallBack) == INTERNET_INVALID_STATUS_CALLBACK)
{
HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_GENERIC_ERROR);
return;
}

//Make the connection to the HTTP server
if (m_sUserName.GetLength())
m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, m_sUserName,
m_sPassword, m_dwServiceType, 0, (DWORD) this);
else
m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, NULL,
NULL, m_dwServiceType, 0, (DWORD) this);
if (m_hHttpConnection == NULL)
{
HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER);
return;
}
//Issue the request to read the file
LPCTSTR ppszAcceptTypes[2];
ppszAcceptTypes[0] = _T("*/*"); //We support accepting any mime file type since this is a simple download of a file
ppszAcceptTypes[1] = NULL;

m_hHttpFile = HttpOpenRequest(m_hHttpConnection, NULL, (LPCTSTR)m_sObject, NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION, (DWORD) this);
if (m_hHttpFile == NULL)
{
HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER);
return;
}

//Should we exit the thread
if (m_bAbort)
{
PostMessage(m_hWnd,WM_HTTPDOWNLOAD_THREAD_FINISHED,0,0);
return;
}

//Issue the request
BOOL bSend = ::HttpSendRequest(m_hHttpFile, NULL, 0, 0, 0);//<----出错地

if (!bSend)
{
HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER);
return;
}

运行到这句:
BOOL bSend = ::HttpSendRequest(m_hHttpFile, NULL, 0, 0, 0)
时跳出一个诊断宏,详细内容如下:
Debug Assertion Failed!
Program:D:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE
File:f:\rtm\vctools\crt_bld\self_x86\crt\src\output.x
Line:2308
Expression: ((state == ST_NORMAL || (state == ST_TYPE))
后面的就略了。

这个东西真是莫名其妙,我起初怀疑是什么地方用了Format字符串的方法,传递的参数类型不对,但是后来想想也不应该在调用这个Winnet库的函数时报错啊。

这段代码在VC6运行完全正常,从VC6转换到VC2005也是正常的,唯独从VC2005从头创建时才有这个问题。
...全文
139 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
周江涛 2006-06-20
  • 打赏
  • 举报
回复
不懂。

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧