• 0

[C] output files & cleanup help.


Question

Currently i am making a program to bind files and ran into a snag. I looked up some public code and what it does is makes a single exe, and when executed outputs 2 file buffers to the directory and executes them with shellexecute. The only problem is, the files are left there.... is there any way to listen for when they close & cleanup? because I cant delete the file immediately after the shellexecute, the file will still be running and and cause a "File still in use error".

here is a snippet of the code:

 fclose(fp);

 if((fp=fopen(file2, "wb"))==NULL) { return; }

 for(i=sobra; i<filesize-1; i++)
	 fputc(content[i], fp);

 fclose(fp);

 if((fp=fopen(file3, "wb+"))==NULL) { return; }

 for(i=filesize+6; i<size-2; i++)
	 fputc(content[i], fp);

 fclose(fp);

ShellExecute(NULL, "open", file2, NULL, NULL, SW_SHOW);
ShellExecute(NULL, "open", file3, NULL, NULL, SW_SHOW);

}

at the end it executes the 2 seperate executables. I need to have them removed when they close the program.

I don't know why this method is used it seems very inefficient.

There are commercial programs which bind everything into 1 executable and upon running it, the code from both is executed without making 2 seperate files in that directory. Well, maybe it does just in a temp directory.... but I'm pretty sure they don't do that.

So either:

a.) how can i cleanup after opening them... since i dont mind using this method.

or

b.) what is the method to PROPERLY bind them together so that the code executes simultaneously within 1 process, without outputting 2 separate files?

any help is much appreciated.

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.