gpt4 book ai didi

c++ - 需要 FtpGetFile 的例子,不工作

转载 作者:太空宇宙 更新时间:2023-11-04 11:35:32 24 4
gpt4 key购买 nike

这是我当前的代码,但它什么也没做。我还希望它在下载完成后打开 do.bat

#include <cstdlib>
#include <iostream>
#include <wininet.h>
using namespace std;

int main(int argc, char *argv[])
{
HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); // Initialization for WinInet Functions
HINTERNET hFtpSession = InternetConnect(hInternet,"server",INTERNET_DEFAULT_FTP_PORT,"user","pass", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0); // Starts a session in this case an FTP session
FtpGetFile(hInternet,"do.bat","C:\\do.bat",FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,0);






InternetCloseHandle(hFtpSession); // Close hFtpSession
InternetCloseHandle(hInternet); // Close hInternet

system("PAUSE");
return EXIT_SUCCESS;
}

最佳答案

哇,不用了,再次感谢,只是一个菜鸟错误。我需要更换

FtpGetFile(hInternet,"do.bat","C:\do.bat",FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,0);

FtpGetFile(hFtpSession,"do.bat","C:\do.bat",FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,0);

#include <cstdlib>
#include <iostream>
#include <wininet.h>
using namespace std;

int main(int argc, char *argv[])
{
HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); // Initialization for WinInet Functions
HINTERNET hFtpSession = InternetConnect(hInternet,"ftp.drivehq.com",INTERNET_DEFAULT_FTP_PORT,"merzu","8067-MPSE", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0); // Starts a session in this case an FTP session
FtpGetFile(hFtpSession,"do.bat","do.bat",TRUE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,0);






InternetCloseHandle(hFtpSession); // Close hFtpSession
InternetCloseHandle(hInternet); // Close hInternet

system("PAUSE");
return EXIT_SUCCESS;
}

关于c++ - 需要 FtpGetFile 的例子,不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23181407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com