将别人开发的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 = @"XXX\Files\Debug\VsTest.exe"; // 外部exe位置

            Process p = new Process();
p.StartInfo.FileName = fexePath;
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start(); while (p.MainWindowHandle.ToInt32() == )
{
System.Threading.Thread.Sleep();
}
SetParent(p.MainWindowHandle, this.Handle);
ShowWindow(p.MainWindowHandle, (int)ProcessWindowStyle.Maximized);

即可:

 

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

C# 将外部exe程序 嵌入到自己的窗体界面的更多相关文章

  1. windows下调用外部exe程序 SHELLEXECUTEINFO

    本文主要介绍两种在windows下调用外部exe程序的方法: 1.使用SHELLEXECUTEINFO 和 ShellExecuteEx SHELLEXECUTEINFO 结构体的定义如下: type ...

  2. C#和asp.net执行外部EXE程序

    这两天研究下.Net的执行外部EXE程序问题,就是在一个程序里通过按钮或其他操作运行起来另外一个程序,需要传入参数,如用户名.密码之类(实际上很类似单点登录,不过要简单的多的多):总结如下: 1.CS ...

  3. c# 调用外部exe程序

    c#调用外部exe程序,首先要 using System.Diagnostics; 然后开启一个新process System.Diagnostics.ProcessStartInfo p=null; ...

  4. exe程序嵌入Winform窗体

    1.新建winform程序,添加一个Panel控件和一个button控件,winform窗体命名为:Mainform: 2.新建一个类文件,方便引用,命名为:exetowinform: 3.Mainf ...

  5. WPF 程序中启动和关闭外部.exe程序

    当需要在WPF程序启动时,启动另一外部程序(.exe程序)时,可以按照下面的例子来: C#后台代码如下: using System; using System.Collections.Generic; ...

  6. C# winform启动外部exe后,如何完全阻断父界面接收事件,扩展waitforexit

    公司的系统搭载了好多奇奇怪怪的exe,以前启动exe后,系统还能接着操作.但是后面又提出额外的需求,说是打开外部exe之后,启动exe的父界面要完全不能进行任何操作.当然按常人所想再加一句waitfo ...

  7. [转]VC中调用外部exe程序方式

    本文转自:http://blog.sina.com.cn/s/blog_486285690100ljwu.html 目前知道三种方式:WinExec,ShellExecute ,CreateProce ...

  8. C#检测外部exe程序弹窗错误,并重启

    private void button2_Click(object sender, EventArgs e) { string mainTitle = System.Configuration.Con ...

  9. 启动外部exe程序

    Process myProcess = new Process();myProcess.StartInfo.FileName = pathName;myProcess.Start();其中的pathN ...

随机推荐

  1. python文件上传的三种方式

    def upload(request): return render(request, 'upload.html') def upload_file(request): username = requ ...

  2. B - Factors of Factorial

    Problem Statement You are given an integer N. Find the number of the positive divisors of N!, modulo ...

  3. Shell-3-文件之名

    1.生成任意大小的文件 [root@localhost tmp]# dd 记录了1+0 的读入 记录了1+0 的写出 1048576字节(1.0 MB)已复制,0.00219263 秒,478 MB/ ...

  4. Java foreach remove问题分析

    原文链接:http://www.cnblogs.com/chrischennx/p/9610853.html 都说ArrayList在用foreach循环的时候,不能add元素,也不能remove元素 ...

  5. [SCOI2010]序列操作 BZOJ1858 线段树

    题目描述 lxhgww最近收到了一个01序列,序列里面包含了n个数,这些数要么是0,要么是1,现在对于这个序列有五种变换操作和询问操作: 0 a b 把[a, b]区间内的所有数全变成0 1 a b ...

  6. Github如何快速添加add文件到暂存区之git add

    git add作用是将代码从工作区提交到暂存区 通常会想到:git add [file1] [file2]   : 这个方法添加文件比较慢,如果文件比较多怎么办? git add *.扩展名 这条命令 ...

  7. window.open 设置高和宽无效

    当设置_self属性时,再设置宽和高就不管用,这个宽高会继承父窗口的宽高! window.open("url","_self","width=100, ...

  8. C#学习之按钮点击事件

    描述:asp.net中服务器控件Button的点击事件OnClientClick和OnClick的区别? 解答:http://www.cnblogs.com/ypfnet/archive/2012/1 ...

  9. FileLoadException: 未能加载文件或程序集"aliyun-net-sdk-cf, Version=1.0.0.0,

    清理缓存解决 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files C:\Windows\Microsoft. ...

  10. rest_framework 的验证,权限,频率

    回到顶部 快速实例 Quickstart 回到顶部 序列化 创建一个序列化类 简单使用 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如json之 ...