2
Answers

Hiding and showing process

hey, i got difficulty hiding and showing lots of instances of console app made in c++, im able to hide them but once hidden i cant show them here is code
when i try hide the programs i am able to get a process.mainwindowhandle, but once hidden mainwindowhandle becomes 0. there a way to get hwnd from pid maybe ?

im using showwindow api call from user32.dll

        [DllImport("user32.dll")]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);


                Process[] lines;
                Process a;
                lines = Process.GetProcesses();

                foreach (Process p in lines)
                {
                    if (p.ProcessName.ToLower() == "prog")
                    {
                        ShowWindow(p.MainWindowHandle, 5);
                        MessageBox.Show(p.MainWindowHandle.ToString());
                    }                  
                }
Answers (2)