Results 1 to 4 of 4

Thread: Detecting program close

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94

    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]

  2. #2
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411
    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)

  3. #3
    jim mcnamara
    Guest
    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;


  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Also a message hook can monitor the appropriate messages (WM_DESTROY, WM_QUIT).
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width