Click to See Complete Forum and Search --> : process problem


pierrede
February 21st, 2006, 11:22 AM
Hi everybody,


Here's my problem :

I want to be able to show or hide a process window while it is running.

Here is my code :

Process p = null;

p = new Process();
p.StartInfo.WorkingDirectory = "c:\\Program Files\\Internet Explorer\\";
p.StartInfo.FileName = "iexplore.exe";

p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

p.Start();
while (!p.HasExited)
{
Application.DoEvents();
if (showProcess)
{
// Which code here ??
}
Thread.Sleep(100);
}







void button_showOrHideProcess_click (...)
{
showProcess = !showProcess;
}




obviously process.startInfo has no effect when process is already running, so how can I make window visible ?

stepi
February 21st, 2006, 03:06 PM
Hi,
In order to make it visible you will have to use the Win32 API FindWindow method and once you have the handler to the IE window you should use SetForegroundWindow to bring it on top of all windows.

pierrede
February 22nd, 2006, 02:44 AM
thanks I wll try this