请大家帮忙看看
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;
}