前段时间有个需求,就是在winform程序里嵌入外部的exe文件,经过查找资料,最终将外部的exe文件完美的嵌入到了winform窗体里了。
由于之前没怎么用过c#,所以对c#并不是很熟悉,下面我的demo中可能会有从网上荡下来的某个方法,如有侵权,可以联系我,不说了,上代码,代码里有详细的注解:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace 内嵌实验
{
public partial class Form1 : Form
{
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 0x10000000;
EventHandler appIdleEvent = null;
Action<object, EventArgs> appIdleAction = null;
Process m_AppProcess;