Hi all. My goal here is to copy the currently used file. Then start the new file and delete the old one. An update sequence if you will.
My code:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
char *file="program.exe";
char *currentfile = argv[0];
CopyFile(currentfile, file, FALSE);
if(file == currentfile){
Sleep(8000);
DeleteFile(argv[1]);
}
else{
ShellExecute(0,"open", file, argv[0], 0, SW_SHOW);
exit(1);
}
return 0;
}
Im stumped trying to figure this out. Any suggestions will be accepted (as long as their helpful =P). I think its trying to delete itself, which is 'not' what im trying to do. So if anyone can help me figure out what im doing wrong i'd be very greatful. Thanx in advance!