static int hWnd = 0;
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
static void Main()
{
Process proc = Process.Start("notepad");
Console.WriteLine("Press any key"); Console.ReadKey();
foreach (Process pr in Process.GetProcesses())
{
if (pr.ProcessName == "notepad")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
}
Console.WriteLine("Press any key"); Console.ReadKey();
if (hWnd != 0)
{
ShowWindow(hWnd, SW_SHOW);
hWnd = 0;
}
Console.WriteLine("Press any key"); Console.ReadKey();
}