当前位置: 代码迷 >> WinCE >> 在WinCE5.0的SDK中用CHttpFile、CInternetSession下载文件不能用,为什么?解决思路
  详细解决方案

在WinCE5.0的SDK中用CHttpFile、CInternetSession下载文件不能用,为什么?解决思路

热度:34   发布时间:2016-04-28 13:30:10.0
在WinCE5.0的SDK中用CHttpFile、CInternetSession下载文件不能用,为什么?
我在WinCE5.0的SDK中用CHttpFile、CInternetSession作了下面一段代码用于下载文件,但是不能用,为什么?哪位有什么好的方法,或者好的源代码,能供我参考
CHttpFile   *file   =   NULL;

TRY
{
CInternetSession   *session   =   NULL;
session   =   new   CInternetSession();
CHttpConnection   *connection   =   NULL;

//   To   do:   specify   actual   server,   port,   login   name   and   password   here
connection   =   session-> GetHttpConnection(server,port,login,password);
file   =   connection-> OpenRequest(1,path);
CString   strRequestHeader   =   "Authorization:   Basic   ";
strRequestHeader  
+=   EncodeBase64(login   +   _T( ": ")   +   password);
file-> AddRequestHeaders(strRequestHeader);
file-> SendRequest();
char   ch;
while(file-> Read(&ch,1))
{
//   To   do:   store   file   content   somewhere:
}

delete   session;
}
CATCH(CInternetException,   pEx)
{
//   To   do:   handle   internet   exceptions   here:
}
END_CATCH


------解决方案--------------------
楼主首先要确认,使用的SDK是否已经集成了HTTP相关的组件。

------解决方案--------------------
这些是WinInet.dll中API的封装吧,wince里没有这样的或者类似的东西,就是full sdk里也没有的
LZ只能放弃偷懒的方式,自己用winsock写吧
------解决方案--------------------
楼主用的是哪个sdk。我也遇到了同样的问题。我的sdk是 2005 smartphone sdk
------解决方案--------------------
可能是能用,采用如下步骤看看
1.在Include <afxinet.h> 之前取消_AFX_NO_INET_SUPPORT的定义
#undef _AFX_NO_INET_SUPPORT
#include <afxinet.h>
2.进入afxinet.h文件中,注释掉CFtpFileFind类和CGopherFileFind类的声明
要看运气了
------解决方案--------------------
安装了Visual Studio 2005 SP1吗?
------解决方案--------------------
WinInet.dll wince5中有,我刚做个一个sdk