Pas de dépendances
#include <windows.h> #include <tchar.h> #include <stdio.h> #include <wininet.h> #pragma comment(lib,"wininet.lib") int main(void) { HINTERNET hInet, hFtp; TCHAR* serveur = _T("ftpperso.free.fr"); TCHAR* utilisateur = _T("fvirtman"); TCHAR* password = _T("xxxxxxxxx"); TCHAR* source = _T("d:/a.txt"); TCHAR* dest = _T("tmp/a.txt"); hInet = InternetOpen(0, INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0); if(hInet == NULL) { printf("InternetOpen Invalid Handle value\n"); exit(-1); } hFtp = InternetConnect(hInet, serveur, INTERNET_DEFAULT_FTP_PORT, utilisateur, password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0); if( hFtp == NULL) { printf("InternetConnect echec : code %d\n",GetLastError()); InternetCloseHandle(hInet); exit(-1); } if (FtpPutFile(hFtp, source, dest, FTP_TRANSFER_TYPE_BINARY, 0)) printf("Fichier ok\n"); else printf("FtpPutFile echec : code %d\n",GetLastError()); InternetCloseHandle(hFtp); InternetCloseHandle(hInet); }
No explanations yet.