Mar 25, 2012 at 12:52pm UTC
#include <wininet.h>
# include <windows.h>
int main()
{
HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); // Initialization for WinInet Functions
if(!hInternet) { return 1; }
// Starts a session in this case an FTP session
HINTERNET hFtpSession = InternetConnect(hInternet,"server",INTERNET_DEFAULT_FTP_PORT,"username","pass", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
if(!hFtpSession) {
InternetCloseHandle(hInternet);
return 1;
}
FtpPutFile(hFtpSession, "C:\\aba.txt","Test.txt", FTP_TRANSFER_TYPE_BINARY, 0);
// Uploads the file C:\\Test.txt onto the FTP server as Test.txt
InternetCloseHandle(hFtpSession); // Close hFtpSession
InternetCloseHandle(hInternet); // Close hInternet
return 0;
}
For some reason i get 2 errors
c:\program files\microsoft visual studio\vc98\include\wininet.h(48) : error C2146: syntax error : missing ';' before identifier 'HINTERNET'
c:\program files\microsoft visual studio\vc98\include\wininet.h(48) : fatal error C1004: unexpected end of file found
What's the reason??
Thanks in advance
Mar 25, 2012 at 3:49pm UTC
Include windows.h before all other headers. If it still get syntax error, then maybe your VC6 instalation is corrupted, upgrade to a more recent version of Visual Studio.