المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Show a hidden console again?



C# Programming
09-16-2011, 01:31 PM
Hi everyone,

we have an GUI application that starts and observes several console processes.
Because it can be lots of processes, we are starting these console applications hidden:

Process process = new Process(); process.StartInfo.FileName = dir + @"\ConsoleApp.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.Start();
So far so good, no shell is showing up!

But if the user closes the user interface (which started these processes) all the console applications are still running. Since they should finish their job, this is more or less ok. But we would like to show each console again, so the user could stop them if necessary or watch output in each shell himself.

Any idea how to show the console applications again?
The preferred approach would be that each console application can show itself. (So they would pop up again even if the GUI simply crashed)

I have looked into the process information, but the MainWindowHandle property is set to null for the console applications, so I can't use it to show the shell.
That's also true for any other combination of startinfo properties which lead to a hidden console.
In contrast, Spy++ shows a hidden window for my hidden console app! So how to obtain the (still hidden) window's handle?
Or any other idea how to show these hidden consoles again?


Cheers, Roland