zoukankan      html  css  js  c++  java
  • C# 将外部exe程序 嵌入到自己的窗体界面

    将别人开发的exe程序,放到自己的窗体里面来运行。

    1.基本功能实现

        首先,在自己的窗体后面加上代码:

            [DllImport("User32.dll", EntryPoint = "SetParent")]
            private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    
            [DllImport("user32.dll", EntryPoint = "ShowWindow")]
            private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);

        然后在需要的地方,加上代码:

                string fexePath = @"XXXFilesDebugVsTest.exe"; // 外部exe位置
    
                Process p = new Process();
                p.StartInfo.FileName = fexePath;
                p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                p.Start();
    
                while (p.MainWindowHandle.ToInt32() == 0)
                {
                    System.Threading.Thread.Sleep(100);
                }
                SetParent(p.MainWindowHandle, this.Handle);
                ShowWindow(p.MainWindowHandle, (int)ProcessWindowStyle.Maximized);

     即可:

     

    【http://www.cnblogs.com/CUIT-DX037/】

  • 相关阅读:
    jqGrid jqGrid 参数
    jqgrid问题总结
    quartz的配置表达式
    Struts2接收参数的几种方式
    Perl爬虫代码
    PHP官方的PECL扩展有问题
    Perl单URL爬虫
    Perl 多进程进度条
    Perl Tk摸索
    hdu 2058 数学题
  • 原文地址:https://www.cnblogs.com/CUIT-DX037/p/7170660.html
Copyright © 2011-2022 走看看