Possible Duplicate:
Restore a minimized window of another application
I want to restore (show and give focus) to an external program.
The problem is that if it is on the tray the MainWindowHandle is 0, so I can not restore the window.
Process[] process = Process.GetProcessesByName("MyApp");
//process.MainWindowHandle == 0 if it is on tray!! :(
I've already searched google and stackoverflow. I found some threads with the same question, but there is no answer to this.
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr windowHandle, ShowWindowFlag flag);
How can I pop the external application out of tray and bring it to taskbar?
I can use FindWindow,
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string className, string windowName);
but if there is more the one process with the same class and title, FindWindow will return only one of them, how can i solve this?