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

阅读 28

2024-05-08

        [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)

0 0 举报