Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WatchDog Thread
#4
watchExec_handle = run("long_running_application_name.exe")
...
clo watchExec_handle

I have to say that run returns not window handle, and it cannot be used with clo. To get window handle, use code like this:

Code:
Copy      Help
int window_handle
run "notepad.exe" "" "" "" 0x800 "- Notepad" window_handle
5
clo window_handle

Or get it later with win(...).

run returns process handle. It can be used with wait, and with some Windows API functions (dll functions), including TerminateProcess.

Code:
Copy      Help
int process_handle
process_handle=run("notepad.exe")
5
TerminateProcess process_handle 1
CloseHandle process_handle

Or:

Code:
Copy      Help
run "notepad.exe"
5
ShutDownProcess win("- Notepad")

TerminateProcess should be used only to terminate hung apps. It does not allow the app to execute any exit code.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)