1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| void FileSubmit()
{
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL)
{
cout << "Error1: " << GetLastError();
}
else
{
hFtpSession = InternetConnect(hInternet, "home***.1and1-data.host", INTERNET_DEFAULT_FTP_PORT, "***", "***", INTERNET_SERVICE_FTP, 0, 0);
if (hFtpSession == NULL)
{
cout << "Error2: " << GetLastError();
}
else
{
if (!FtpPutFile(hFtpSession, "text.txt", "/text.txt", FTP_TRANSFER_TYPE_BINARY, 0))
{
cout << "Error3: " << GetLastError() << "\n";
DWORD dwInetError;
DWORD dwExtLength = 1000;
TCHAR *szExtErrMsg = NULL;
TCHAR errmsg[1000];
szExtErrMsg = errmsg;
int returned = InternetGetLastResponseInfo(&dwInetError, szExtErrMsg, &dwExtLength);
printf("dwInetError: %d Returned: %d\n", dwInetError, returned);
_tprintf(_T("Buffer: %s\n"), szExtErrMsg);
}
}
}
} |
Partager