Announcement

Collapse
No announcement yet.

Detect graceful shutdown of app

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detect graceful shutdown of app

    Does anyone know how to detect when my application is being asked gracefully to shut down? I know you can't 'detect' TerminateProcess() as such, but when Windows gets shut down it asks apps to close gracefully and gives them time to 'clean up' before they either kill themselves or die to a delayed call to TerminateProcess
    anyone know how to trap that? i was thinking something like this might work, but it doesnt:

    Code:
    #Compile Exe
    #Include "Win32Api.Inc"
     
    CallBack Function DlgProc
      Select Case CbMsg
         Case %WM_QUIT:
              OPEN "C:\quitlog.txt" FOR APPEND AS #1
               PRINT #1, "Quit at " & TIME$
              CLOSE #1
      End Select
    End Function
     
    Function PbMain
      Local hDlg As Long
      Dialog New 0 ,"Detect call to ExitProcess()",,, 200, 30, %WS_SYSMENU Or %WS_CAPTION Or %WS_MINIMIZEBOX To hDlg
      Dialog Show Modal hDlg, Call DlgProc
    End Function

    ------------------
    -

  • #2
    Solved!
    I just had to change %WM_QUIT to %WM_CLOSE and it detected it

    Thanks, and sorry for the inconvenience


    ------------------
    -

    Comment

    Working...
    X