显示其他应用窗口

//使用
       Process[] instance = Process.GetProcessesByName("dbeaver");
       HandleRunningInstance(instance[0]);



        private static void HandleRunningInstance(Process instance)
        {
            ShowWindowAsync(instance.MainWindowHandle, 3); //显示大小
            SetForegroundWindow(instance.MainWindowHandle); //窗口前置
        }
/*
        private const int SW_HIDE = 0;              //常量,隐藏
        private const int SW_SHOWNORMAL = 1;        //常量,显示,标准状态
        private const int SW_SHOWMINIMIZED = 2;     //常量,显示,最小化
        private const int SW_SHOWMAXIMIZED = 3;     //常量,显示,最大化
        private const int SW_SHOWNOACTIVATE = 4;    //常量,显示,不激活
        private const int SW_RESTORE = 9;           //常量,显示,回复原状
        private const int SW_SHOWDEFAULT = 10;      //常量,显示,默认
         */
        [DllImport("User32.dll")]
        private static extern bool ShowWindowAsync(System.IntPtr intptr, int show_type);

        [DllImport("User32.dll")]
        private static extern bool SetForegroundWindow(System.IntPtr intptr); 

你可能感兴趣的:(c#)