|
-
Sep 29th, 2001, 02:12 PM
#1
Thread Starter
Lively Member
Detecting program close
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.
"Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
-- Judas Priest
My email is [email protected]
-
Sep 29th, 2001, 10:39 PM
#2
Hyperactive Member
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...
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Sep 29th, 2001, 11:23 PM
#3
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;
}
-
Sep 30th, 2001, 06:43 AM
#4
Frenzied Member
Also a message hook can monitor the appropriate messages (WM_DESTROY, WM_QUIT).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|