/// <summary> /// выборка всех запущенных приложений /// </summary> /// <param name="id">ид процесса приложения</param> /// <returns>дескриптор окна</returns> static private IntPtr enumID(int id) { IntPtr hwnd = IntPtr.Zero; bool flg = true; WinApi.EnumWindows((hWnd, lParam) => { if (WinApi.IsWindowVisible(hWnd) && (WinApi.GetWindowTextLength(hWnd) != 0)) { if (WinApi.IsIconic(hWnd) != 0 && WinApi.GetPlacement(hWnd).showCmd == WinApi.ShowWindowCommands.Minimized && flg) { hwnd = findCurProc(id, hWnd, out flg); } else { ; } } return(true); }, IntPtr.Zero); return(hwnd); }
/// <summary> /// выборка всех запущенных приложений /// </summary> /// <param name="id">ид процесса приложения</param> private static void Enum(int id) { WinApi.EnumWindows((hWnd, lParam) => { if (WinApi.IsWindowVisible(hWnd) && (WinApi.GetWindowTextLength(hWnd) != 0)) { if (WinApi.IsIconic(hWnd) != 0 && WinApi.GetPlacement(hWnd).showCmd.ToString() == "Minimized") { FindCurProc(id, hWnd); } else { ; } } return(true); }, IntPtr.Zero); }
/// <summary> /// Активация окна /// </summary> private static void SwitchToCurrentInstance(IntPtr hWnd) { if (hWnd != IntPtr.Zero) { // Restore window if minimised. Do not restore if already in // normal or maximised window state, since we don't want to // change the current state of the window. if (WinApi.IsIconic(hWnd) != 0) { WinApi.ShowWindow(hWnd, WinApi.SW_RESTORE); } else { ; } // Set foreground window. WinApi.SetForegroundWindow(hWnd); } }