大家快来看呀,urldownloadtofile耍赖呀!!!!!!!

wuoaimaomi 2009-01-28 06:42:24
我调用以下代码下载网页文件:
URLDownloadToFile 0&, "www.sohu.com", "c:\aaa.txt", 0&, 0&
可执行后,系统没任何表示,打开C盘,什么文件也没有,怎么URLDOWNLOADTOFILE这么无赖呀,怎么办呀,各位???
...全文
98 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
opens555 2009-01-28
  • 打赏
  • 举报
回复
不懂,帮顶
noenoughmemory 2009-01-28
  • 打赏
  • 举报
回复
不懂,帮顶
fishion 2009-01-28
  • 打赏
  • 举报
回复
UpdateData(true);
//m_SiteInfo为控件ID_EDIT_CONTENT读应的变量
m_SiteInfo="";
//将变量值传给对应控件

UpdateData(false);
//CDialog::OnOK();
CInternetSession mySession(NULL,0);
CHttpFile* myHttpFile=NULL;
m_SiteInfo="连接到站点"+m_SiteName+"\r\n";
UpdateData(false);

CString myData;
myHttpFile=(CHttpFile*)mySession.OpenURL(m_SiteName);
while(myHttpFile->ReadString(myData))
{
m_SiteInfo=m_SiteInfo+"\r\n";
m_SiteInfo+=myData;
}
myHttpFile->Close ;
mySession.Close ;
UpdateData(false);

只不过如果是下载网页代码的,一般是用我上面的方面
fishion 2009-01-28
  • 打赏
  • 举报
回复
看错了,是说路径要存在,而不是说文件要存在
fishion 2009-01-28
  • 打赏
  • 举报
回复
szFileName
A pointer to a string value containing the name or full path of the file to create for the download. If szFileName includes a path, the target directory must already exist.

这个是重点,说如果是一个全路径的,当前的文件要存在
fishion 2009-01-28
  • 打赏
  • 举报
回复
HRESULT URLDownloadToFile( LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);Parameters

pCaller
A pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component, if the caller is an ActiveX component. If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component, such as an ActiveX control in the context of an HTML page. This parameter represents the outermost IUnknown of the calling component. The function attempts the download in the context of the ActiveX client framework, and allows the caller container to receive callbacks on the progress of the download.
szURL
A pointer to a string value that contains the URL to download. Cannot be set to NULL. If the URL is invalid, INET_E_DOWNLOAD_FAILURE is returned.
szFileName
A pointer to a string value containing the name or full path of the file to create for the download. If szFileName includes a path, the target directory must already exist.
dwReserved
Reserved. Must be set to 0.
lpfnCB
A pointer to the IBindStatusCallback interface of the caller. By using OnProgress, a caller can receive download status. URLDownloadToFile calls the OnProgress and OnDataAvailable methods as data is received. The download operation can be canceled by returning E_ABORT from any callback. This parameter can be set to NULL if status is not required.

18,356

社区成员

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

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