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;
}
				

你可能感兴趣的:(编程,互联网,服务器,File,command,internet)