Hi folks. I inherited an FTP program from a colleague that left the team so i have to do C++ programming now. The problem is that the FTP program throws up winsock errors. the FTP skips these errors but after a while it terminates the program. So I writing another prgram that monitors the FTP process. When it starts the Send/Receive process i write to an inifile the date and process=1 and at end of process i write date and process=0. in the monitor program i read the inifile the process and date, if process = 1 and date <10 minutes old the forcibly temainate the FTP program, if process = 0 then terminate every 30 minutes.

The problem i have is that i cant seem to get the time difference in minutes when i read from the inifile, ie diff.
the other problem i have is that i donot know the commands ion C++ to terminate and start the exe of the FTP program

I am a total newbie to C++ so any assistance you'll can provide is greatly appreciated. Here is the code of the part where i calculate the time difference. :

TIniFile* IniFileB;
IniFileB =new TIniFile ("C:\\GCOS\\FTP\\EXE\\ftpbusy.ini" );

double startdate;
int Process;
long diff;
long end;
diff = 0;
String sRightVal;

Process = IniFileB->ReadInteger("Main","Process",10);
startdate = IniFileB->ReadDateTime("Date","DT", Now());

diff = difftime(startdate,time);
delete IniFileB ;

difftime returns the difference in time in seconds, not minutes, so you would have to divide by 60 to get the number of minutes.

difftime wants two time_t objects:

http://www.cplusplus.com/reference/clibrary/ctime/difftime/

double difftime ( time_t time2, time_t time1 )[B];[/B]

I don't know what time represents here:

diff = difftime(startdate,time)[B];[/B]

Is time a variable you've declared somewhere? If so, check to make sure time is not a reserved word in C++. You have startdate declared as a double. It needs to be a time_t object according to the spec.

Check out the example in the link I posted. Does your code compile?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.