Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent "end process tree" from terminating the programs mine has started?

I am trying to execute an EXE 'two.exe' from another application 'one.exe' in Delphi XE2 using ShellExecute.

ShellExecute(0, 'open', 'two.exe', nil, nil, SW_NORMAL);

It works perfectly, but whenever I terminate application 'one.exe' (the parent app) from Task Manager's process tab, using the "end process tree" option, the application 'two.exe' also gets terminated.

How can I prevent my ShellExecuted application from getting terminated like this?

like image 587
jimsweb Avatar asked May 15 '12 16:05

jimsweb


1 Answers

Ok, not very nice solution... but tested with success ;o)

ShellExecute(0, 'open', 'cmd', 
  PChar('/C  start "" "' + Application.ExeName + '"'), nil, SW_HIDE);

enter image description here

The first is manually launched... his child with regular shellexecute call... The last one, with the shellexecute + cmd trick...

/C explanation

like image 111
Whiler Avatar answered Sep 20 '22 19:09

Whiler