需要FtpGetFile的例子,不工作

这是我目前的代码,但它什么都不做。 我也想在下载完成后打开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; } 

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

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; }