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());
}
}
Loading
Daniel van PletzenPosted Sep 20, 2007, 12:31 PM
AlanPosted Sep 20, 2007, 11:57 AM
Couldn't you get the window handle before you hide it and then store it in an IntPtr field so that you can reshow the window with it later?
You wouldn't then have to call Process.MainWindowHandle again at that point.