ok… here is some C++ i need help with. i know which line is wrong and ill show you in a sec, but im not quite sure whats wrong with it, it worked perefectly today, then i go to recompile again, and its not working anymore…
//Link
// "../../../../../Dev-Cpp/lib/libwininet.a"
// "../../../../../Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib/WinInet.Lib"
#include <iostream> //for cout and cin
#include <fstream> //for files ops
#include <string> //for string ****..I don't think we need this
#include <Winsock2.h> //for sockets...we don't need this for ftp though
#include <Wininet.h> //I think we ned this for ftp
#include <shlobj.h>
#include <windows.h>
#include <objbase.h>
using namespace std; ///yea...
int cnt = 70;
void back(int);
void space(int);
void dots(char);
void spin();
void chr(char, int);
int main(int argc, char *argv[])
{
char ftpserver[] = "**edited and hidden for post**"; //this ALL have to be a char var...not string
char ftpuser[] = "**edited and hidden for post**"; //or lese you have to convert them with .c_str()
char ftppass[] = "**edited and hidden for post**";
char filepath[] = "**edited and hidden for post**";
HINTERNET hSession; //I feel like an IdIOt
HINTERNET hService;
DWORD Stat;
cout << "[Checking for Connection] ";
dots('.');
cout << "\b";
spin();
spin();
cout << " ";
//Wait till computer is online
while(InternetGetConnectedState(&Stat, 0) != TRUE)
{
dots('.');
cout << "\b";
spin();
spin();
cout << " ";
}
cout << endl;
cout << ".::Connected::.\a\a\a" << endl; //You better know what those 'a''s do...
//Wait a few more seconds just in case computer isn't fully connected
Sleep(2000); //slepps 2,000 MILIeconds
//open a...socket type thing..a session
hSession = InternetOpen("FTP Connector", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
//open connection to ftp server
hService = InternetConnect(hSession, ftpserver, INTERNET_DEFAULT_FTP_PORT, ftpuser, ftppass, INTERNET_SERVICE_FTP, 0, 0);
if(hService != NULL)
cout << "Successful Connection to FTP server" << endl; //formatting is important...suck it up
else
cout << "Could not connect to FTP server: You may have an incorrect username/password!" << endl;
int ret = FtpPutFile(hService, filepath, "**edited and hidden for post**" , FTP_TRANSFER_TYPE_BINARY, 0);
if(ret)
cout << "Successfullly uploaded file: " << filepath << "
to server: " << ftpserver << endl;
else
cout << "Could not upload file: " << filepath << endl;
InternetCloseHandle(hService);
InternetCloseHandle(hSession); //always make sure to close your handles after you are done
system("pause"); //thank you...np...one last thing...
return 0;
}
void space(int i)
{
for(int j = 0; j < i; j++)
cout << " ";
}
void back(int i)
{
for(int j = 0; j < i; j++)
cout << "\b";
}
void spin()
{
cout << "-";
Sleep(cnt);
cout << "\b \b";
cout << "/";
Sleep(cnt);
cout << "\b \b";
cout << "|";
Sleep(cnt);
cout << "\b \b";
cout << "\\";
Sleep(cnt);
cout << "\b \b";
cout << "-";
Sleep(cnt);
cout << "\b \b";
cout << "/";
Sleep(cnt);
cout << "\b \b";
cout << "|";
Sleep(cnt);
cout << "\b \b";
cout << "\\";
Sleep(cnt);
cout << "\b \b";
}
void dots(char c)
{
int n = 10;
for(int i = 0; i < n; i++)
{
cout << c;
Sleep(cnt);
}
for(int i = 1; i <= n; i++)
{
back(i);
space(i);
Sleep(cnt);
}
back(n);
/*
for(int i = 0; i < 5; i++)
cout << "\b";
for(int i = 0; i < 5; i++)
cout << " ";
for(int i = 0; i < 5; i++)
cout << "\b";
*/
}
void chr(char c, int i)
{
for(int j = 0; j < i; j++)
cout << c;
}
the thread thats wrong is
int ret = FtpPutFile(hService, filepath, "/asd/newfile.inf" , FTP_TRANSFER_TYPE_BINARY, 0);
and im telling you now, unless you know C++ like me, you wont understand this, so dont even try if you dont knwo any…
thx