Hey Guys
i was wondering if there is anyway to detect when a user has closed an application. i have launched teh app using shellexecute and want to delete the file it opened when the program is closed.
Printable View
Hey Guys
i was wondering if there is anyway to detect when a user has closed an application. i have launched teh app using shellexecute and want to delete the file it opened when the program is closed.
u could Set a timer and use FindowWindow to find the hwnd of the window u opened by its caption and if the return value is 0 then the window can't be found and its been closed... then u could do delete the file and kill the timer.. if u need some code to handle this tell me and i will code something up right quick for u...
Get the process handle from ShellExecuteEx (use that instead of ShellExecute), then you can use WaitForSingleObject until the shelled object closes.
PHP Code:#include <windows.h>
SHELLEXECUTEINFO sh;
strcpy(sh.filename,"myfile.exe");
// there are other parts of the struct to fill out...
int ret = Shellexecute(sh);
// this pauses the program and waits until the
// shelled programn exits
While( WaitForSingleObject(sh.hProcess,INFINITE) == 278{
Sleep 2;
}
Also a message hook can monitor the appropriate messages (WM_DESTROY, WM_QUIT).