以c#形式打开.exe [英] open .exe in form c#

查看:86
本文介绍了以c#形式打开.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想知道如何使用我在项目外调用应用程序(.exe)的按钮来创建表单,并且包含在表格。



我见过很多例子,但是我还做不到。



我是目前正在使用Visual Studio 2010



提前致谢,



问候

Hello,

I would like to know how I can create a form using a button I call an application (. Exe) outside the project and is contained within the form.

I have seen many examples but I can not do it yet.

I am currently using Visual Studio 2010

Thanks in advance,

regards

推荐答案

using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Form1 : Form
{
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public Form1()
{
Process proc = Process.Start("notepad.exe");
proc.WaitForInputIdle();
Form1.SetParent(proc.MainWindowHandle, this.Handle);
}
}


这篇关于以c#形式打开.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆