0
点赞
收藏
分享

微信扫一扫

Windows安装RabbitMQ教程(附安装包)

一只1994 2024-05-08 阅读 28
c#
        [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
        static void Main(string[] args)
        {
            Process p = Process.GetProcessesByName("QQ").FirstOrDefault();
            IntPtr myPtr = p.MainWindowHandle;
            判断这个窗体是否有效
            if (myPtr != IntPtr.Zero)
            {
                Console.WriteLine("找到窗口");
                SetForegroundWindow(myPtr);
                ShowWindow(myPtr,3);
            }
            else 
            { 
                Console.WriteLine("没有找到窗口"); 
            }
            Console.ReadKey();
        }
举报

相关推荐

0 条评论