home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CHIP_CD_2004-07.iso / software / nncron_hit / files / nncron189.exe / plugins / procwin.spf < prev    next >
Text File  |  2003-06-26  |  2KB  |  62 lines

  1. \ File:         procwin.spf
  2. \ Author:       Nicholas Nemtsev
  3. \ Description:  Soft terminating of processes with windows closing.
  4. \ Date: 20.06.03
  5. \ nnCron tries to close all windows of a process at 1st step.
  6. \ and after it nnCron terminate the process (KILL), if it need.
  7. \ Before using this plugin you must insert "INCLUDE procwin.spf"
  8. \ into nncron.ini
  9. \ Usage: PROC-CLOSE: procname.exe
  10.  
  11. DECIMAL
  12. WINAPI: GetWindowThreadProcessId
  13.  
  14. \ DWORD GetWindowThreadProcessId(
  15. \  HWND hWnd,             // handle to window
  16. \  LPDWORD lpdwProcessId)  // process identifier
  17.  
  18. :NONAME { buf hwnd \ pid1 -- ? }
  19.     AT pid1 hwnd GetWindowThreadProcessId DROP
  20.     buf @ pid1 =
  21.     IF
  22.         hwnd buf CELL+ GLOBAL AppendNode LOCAL
  23.     THEN
  24.     TRUE
  25. ; WNDPROC: AddProcWindow
  26.  
  27. : GET-PROC-WINDOWS ( list pid -- )
  28.     2 RALLOT >R
  29.     R@ ! R@ CELL+ 0!
  30.     R@ ['] AddProcWindow EnumWindows DROP
  31.     [NONAME
  32.  
  33.     NONAME] R@
  34.     RDROP
  35.     2 RFREE
  36. ;
  37.  
  38. :NONAME { pid hwnd \ pid1 -- }
  39.     AT pid1 hwnd GetWindowThreadProcessId DROP
  40.     pid pid1 =
  41.     IF
  42. \        ." ProcWND=" pid . pid1 . hwnd . CR
  43.         0 0 16 ( <- WM_CLOSE) hwnd PostMessageA DROP
  44.     THEN
  45.     TRUE
  46. ; WNDPROC: CloseProcWindow
  47.  
  48. \ Closes all windows of process and terminates this process after it.
  49. : PROC-CLOSE { a u -- }
  50.     a u PROC-EXIST? ?DUP
  51.     IF
  52.         ['] CloseProcWindow EnumWindows DROP
  53.         1000 PAUSE
  54.         a u KILL \ φα Γ± ΩΦΘ ±δ≤≈αΘ, σ±δΦ ∩≡ε÷σ±± εΩε°σΩ φσ Φ∞σσ≥
  55.     THEN
  56. ;
  57.  
  58. : PROC-CLOSE: eval-string, POSTPONE PROC-CLOSE ; IMMEDIATE
  59.  
  60. \ Usage: PROC-CLOSE: xxxx.exe
  61. \ e.g. PROC-CLOSE: winword.exe
  62.