Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. // Declaration of CloseHandle as local external function
  2. Function boolean CloseHandle (ulong hObject) Library "KERNEL32.DLL"
  3. ....
  4. // Start another process
  5. CreateProcess (lul_null, "~"" + as_command + "~" " + as_arguments, lul_null, lul_null, TRUE, 32, lul_null, ls_null, lstr_startupinfo, lstr_proc)
  6.  
  7. // Just for test
  8. gf_log_into_file("HANDLE="+string(lstr_proc.ul_process))
  9. WaitForInputIdle(lstr_proc.ul_process, al_millisecs)
  10.  
  11. // Wait until the process closes
  12. do
  13. do while Yield()
  14. loop
  15. lul_rc = WaitForSingleObject (lstr_proc.ul_process, al_millisecs)
  16. loop while lul_rc = WAIT_TIMEOUT
  17.  
  18. // get exit code
  19. GetExitCodeProcess(lstr_proc.ul_process, ref al_ret)
  20. // this one still returns TRUE!!
  21.  
  22. gf_log_into_file("HANDLE="+string(lstr_proc.ul_process))
  23.  
  24. // closehandle returns FALSE 2 times
  25. if NOT CloseHandle(lstr_proc.ul_thread) then lul_rc = GetLastError()
  26. // lul_rc = 6
  27. if NOT CloseHandle(lstr_proc.ul_process) then lul_rc = GetLastError()
  28. // lul_rc = 6 which means ERROR_INVALID_HANDLE. But why?? For GetExitCodeProcess(..) one line above the handle was still OK
  29.  
  30. gf_log_into_file("HANDLE="+string(lstr_proc.ul_process))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement