Sunday, July 12, 2009

Why doesn't shell process from Visual C++ hide?

Hi all,





I'm writing a GUI for an old shell program which I don't want to dig into too much. I start the shell program and give it some input and read its output.


Simple enough.





But it doesn't want to hide although I've set it to "Hidden". The shell process also locks the gui program.





What to do about this?





The strange thing is if I add a breakpint after the process is started in Visual C++ 2003 (7.1) it does hide, as if some interuption is all that is needed...








Thanks in advance,


Matti Zemack








mainProcess = new Process();


ProcessStartInfo* myProcessStartInfo = new ProcessStartInfo(S"oldShellProgram.exe")...


myProcessStartInfo-%26gt;UseShellExecute = false;


myProcessStartInfo-%26gt;RedirectStandardOu... = true;


myProcessStartInfo-%26gt;RedirectStandardIn... = true;


myProcessStartInfo-%26gt;WindowStyle =


ProcessWindowStyle::Hidden;


myProcessStartInfo-%26gt;Arguments =


StartupStringTextBox1-%26gt;Text;


mainProcess-%26gt;StartInfo = myProcessStartInfo;


mainProcess-%26gt;Start();

Why doesn't shell process from Visual C++ hide?
it locks the GUI because you're using a single thread. Therefore the event message loop can't be processed, which initiates the re-drawing of the element and all mouse and keyboard elements.





To avoid that, you have to spawn your process in a separate thread.





I also don't think that you can "hide" the window so easily - my guess is that you can only hide native Win32 applications. But if this is a console application, then maybe it's not possible - or maybe you just need a more complicated API. I would ask on codeguru.com - they usually know a lot about windows APIs.

land survey

No comments:

Post a Comment