how to cancel stating a process when the computer is shutting down?
<p>I have a program that uses an external process to complete its work using <code>ProcessName.Start()</code>, the problem is that when windows is shutting down I want to know that it is shutting down before starting the process, because if the application start the process while shutting down windows shows a message that the process was unable to start correctly (ERROR CODE 0xc0000142).</p>

<p>The main Application is a C# Windows forms application with a notification icon, and the external process is a native console application written in old C (and that is for a good reason).</p>

<p>I used some System events like SessionEnding, and overridden the WndProc to handle windows messages but without success, the application receive these events and messages somewhat late and the application would have started the process and the Error message is shown.</p>

<p>I hope someone can help me on this.</p>

<p>Thnx    </p>
