本文主要介绍通过c#来启动外部exe(第三方软件)并嵌入到主窗口运行,在自己的应用程序中运行
一、启动外部exe相对简单
IntPtr hcalc; //用以存储目标窗口句柄
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = Environment.ExpandEnvironmentVariables(exePath); //exePath要启动的外部应用程序路径
ps.WorkingDirectory = @"" ; //指定工作目录以确定相对路径
Process proc = Process.Start(ps);
new Thread(new ThreadStart(() =>
{
while (hcalc == IntPtr.Zero) //循环目标窗口启动完成
{
Thread.Sleep(10);