WinInet 实现ftp断点续传

WinInet 提供对常用的互联网协议,包括 Gopher、 FTP 和 HTTP 访问。 使用 WinInet,可以不必处理 WinSock、 TCP/IP 或特定的互联网协议的详细信息写入 Internet 客户端应用程序的编程中,更高的级别。

FTP 通常公开要将一个文件附加到另一个"追加"命令。WinInet 不直接公开此功能。

在 Internet Explorer 3.0 和 4.0 中,这一问题的解决方法是从服务器下载文件、 将附加到该客户端然后上载该文件备份到服务器上。

从开始 Internet Explorer 5,FTP 命令可以直接发送到 FTP 服务器使用 FtpCommand,如下所示:
CHAR szTemp[256];
wsprintf (szTemp, "APPE %s", "DestFile.txt");

bRet = FtpCommand( hConnection,// WinInet Connection handle
TRUE,// Yes, I expect a response
FTP_TRANSFER_TYPE_ASCII,// I'm receiving ASCII
szTemp,// This is the FTP command I am passing
0,// No context needed
&hResponse);// The handle to read the response 
if (!bRet)
{
cout << "FtpCommand failed, error: " << GetLastError() << endl;
return;
}

wsprintf (szTemp, "This data will be appended to the file");

DWORD dwSize;
if (!InternetWriteFile (hResponse, (LPVOID)szTemp, lstrlen(szTemp)+1, &dwSize))
{
cout << "InternetWriteFile failed, error: " << GetLastError() << endl;
return;
}
				
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值