winform嵌入可执行

来源:互联网 发布:matlab 2017b for mac 编辑:程序博客网 时间:2024/06/05 11:00

using System.Runtime.InteropServices;/*调用winapi*/

        [DllImport("user32.dll", SetLastError = true)]        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);        [DllImport("user32.dll", SetLastError = true)]        private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);        void 嵌入可执行()        {            System.Diagnostics.Process 本地系统进程 = System.Diagnostics.Process.Start(System.Environment.CurrentDirectory + @"\FreeCell.exe");            while (FindWindow(null, "FreeCell") == IntPtr.Zero)            {                System.Threading.Thread.Sleep(100);                Application.DoEvents();            }            System.Threading.Thread.Sleep(1000);            SetParent(本地系统进程.MainWindowHandle, 五行农历容器.Handle);        }


 

原创粉丝点击