| 关键词: include HINTERNET hFtpSession ftp HINSTANCE INTERNET InternetCloseHan NULL str int |
#include <windows.h>#include <wininet.h>#include <cstdlib>#include <ctime>#include <iostream>#include<stdio.h>#include<time.h>#pragma comment(lib, "wininet") int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){srand((unsigned)time(0));int random_integer = rand();char str[1024];srand(time(0));sprintf(str,"%.5d_file.txt",rand()%100000);HINTERNET hInternet;HINTERNET hFtpSession;hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);hFtpSession = InternetConnect(hInternet, "ftp.name.com", INTERNET_DEFAULT_FTP_PORT, "user-name", "user-password", INTERNET_SERVICE_FTP, 0, 0);FtpPutFile(hFtpSession, "C:\\log.txt", str, FTP_TRANSFER_TYPE_BINARY, 0);InternetCloseHandle(hFtpSession);InternetCloseHandle(hInternet);Sleep(2000);MessageBox(NULL, "Successfully uploaded to ftp server!", "Ftp Upload", MB_OK);return 0;} |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|