日期:2014-05-17  浏览次数:20792 次

显示另一个被隐藏的程序 ?
有2个程序A.exe 与 B.exe
B.exe 被隐藏   //this.Visible = False;

问题:
想要用 A.exe 来显示 B.exe

该怎么实现?......

------解决方案--------------------
调用2个API函数,用FindWindow找到另一个程序窗口的句柄,用ShowWindow显示出来。
------解决方案--------------------
[System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern IntPtr FindWindow(string strclassName, string strWindowName);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);



        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            IntPtr trayHwnd = FindWindow(null, null);//如果通过窗口类查找目标程序填写第一个参数,如果通过窗口的标题查找程序填写第二个参数,相反另一个不用的参数填写为null
            if (trayHwnd != IntPtr.Zero)
            {
                ShowWindow(trayHwnd, 0);//为0隐藏,为1显示
            }
        }

------解决方案--------------------
注册系统消息。
A通过广播消息通知B。
B通过重载WndProc()得到来自A的消息
API:
注册消息:RegisterWindowMessage
发消息:SendMessage


------解决方案--------------------
引用:
Quote: 引用: