dai460973037 发表于 2015-11-6 07:39:00

wininet 实现ftp上传

#include "stdafx.h"
#include <windows.h>
#include <wininet.h>
#include <iostream>
#pragma comment(lib, &quot;Wininet&quot;)
using namespace std;
void FileSubmit()
{
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL)
{
cout << &quot;Error: &quot; << GetLastError();
}
else
{
hFtpSession = InternetConnect(hInternet, L&quot;ftp ip address&quot;, INTERNET_DEFAULT_FTP_PORT, L&quot;username&quot;, L&quot;passwrod&quot;, INTERNET_SERVICE_FTP, 0, 0);
if (hFtpSession == NULL)
{
cout << &quot;Error: &quot; << GetLastError();
}
else
{
if (!FtpPutFile(hFtpSession, L&quot;e://file.txt&quot;, L&quot;/file.txt&quot;, FTP_TRANSFER_TYPE_BINARY, 0))
{
cout << L&quot;Error: &quot; << GetLastError();
}
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
FileSubmit();
return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: wininet 实现ftp上传