class Program { private const int SW_SHOWNORMAL = 1; private const int SW_SHOWMINIMIZED = 2; private const int SW_SHOWMAXIMIZED = 3; [DllImport("user32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] private static extern bool MinimizeWindow(System.IntPtr hwnd); static void Main(string[] args) { System.Diagnostics.Process thisProcess = System.Diagnostics.Process.GetCurrentProcess(); System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("notepad"); foreach (System.Diagnostics.Process process in processes) { if (process == thisProcess) continue; System.IntPtr handle = process.MainWindowHandle; if (handle == System.IntPtr.Zero) continue; IntPtr s1 = process.MainWindowHandle; ShowWindowAsync(s1, SW_SHOWMINIMIZED); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)