Determine when a windows process is closing

1

I want to determine in vb code when a windows process is closed (which I have previously opened). But I get an error when I want to run:

Call GetExitCodeProcess(handle_Process, lp_ExitCode)

And the error message is: "Attempt to read or write to protected memory, this often indicates that there is another damaged memory."

I am based on the code on the following page: Open process and wait for it to end

    
asked by nasck 21.11.2016 в 23:47
source

2 answers

1
' En esta parte obtiene los permisos del proceso para
' modificarlo (por decirlo de algun manera)
' Sin esto el programa no funciona, Asegurate de tener esta parte en tu codigo
handle_Process = OpenProcess(PROCESS_QUERY_INFORMATION, False, id_process)  


//Mientras lp_ExitCode = STATUS_PENDING, se ejecuta el do  
Do  

    Call GetExitCodeProcess(handle_Process, lp_ExitCode)  
    
answered by 22.11.2016 в 08:07
1

This can happen if you are using the debugger (managed code) and also use native libraries.

Some solutions may be:

  • Use debuggers without managed code,
  • avoid the shift operation in debug and then try in release, or
  • disable the runtime exception that is skipping you, if available, in Debug-> Windows-> Configuring exceptions.
answered by 22.03.2018 в 17:27