请大家帮忙看看

nemo 2003-03-18 01:43:13
最近编程总发现在连接时出错(编译时没错),如:
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
出错程序如下:这是一个用http协议下载的程序,还不知能不能行

#include <afxinet.h>
void main()
{
unsigned char buffer[512];
int bytes = 1;
int totalRead = 0;
CString fileName = "";
CString query = "";
CString url = "http://192.168.5.63";
CHttpFile* file = NULL;
CInternetSession* inetSession = NULL;

try{

inetSession = new CInternetSession("AppName",1,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

file = (CHttpFile*)inetSession->OpenURL(LPCTSTR(url),1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);

// get size of remote file
file->QueryInfo(HTTP_QUERY_CONTENT_LENGTH,query);

fileName = file->GetFileURL();
fileName.Delete(0,fileName.ReverseFind('/')+1);


}
catch(CInternetException* e) {
e->ReportError();
e->Delete();
// abort here!
}
/*catch(CFileException* e) {
e->ReportError();
e->Delete();
// abort here!
}
*/

FILE* f = fopen(LPCTSTR(fileName),"wb+");
while(bytes>0 && totalRead<atol(query))
{
bytes = file->Read(buffer,512);
fwrite(buffer,bytes,1,f);
totalRead+=bytes;
}
fflush(f);
fclose(f);
file->Close();
delete inetSession;
}
...全文
46 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nemo 2003-03-18
  • 打赏
  • 举报
回复
选了,没有用
Iamapuma 2003-03-18
  • 打赏
  • 举报
回复
你选择no using mfc试试看

18,356

社区成员

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

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