WPF下能不能在控件里打开一个新程序?
时间:2011-12-08
来源:互联网
目的是在自己的程序中的一个控件里打开另外一个程序,这样那一个程序的位置就会固定在我们自己的控件里,不用两个程序相互切换了。
用winform是可以实现的,代码如下:
C# code
当然还有缺陷,比如可以把里面的程序移动到边界外等。
现在如果用WPF能否实现相同的功能?目前我无法获取控件的Handle
用winform是可以实现的,代码如下:
C# code
System.Diagnostics.Process.Process p = System.Diagnostics.Process.Start("C:\\Windows\\system32\\notepad.exe"); //notepad"); p.WaitForInputIdle(); SetParent(p.MainWindowHandle, panel1.Handle); ShowWindowAsync(p.MainWindowHandle, 3);
当然还有缺陷,比如可以把里面的程序移动到边界外等。
现在如果用WPF能否实现相同的功能?目前我无法获取控件的Handle
作者: nomad_aa 发布时间: 2011-12-08
wpf可以实现这样的功能
以下是我 wpf调用winform的应用程序
string file = string.Format("{0}G2", System.AppDomain.CurrentDomain.BaseDirectory);
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
Info.FileName = "IVM_DVS_G2.exe";//设置外部程序名
string ip=dtDvs.Rows[0]["dvsIp"].ToString();
string port=dtDvs.Rows[0]["port"].ToString();
string useName=dtDvs.Rows[0]["userName"].ToString();
string password=dtDvs.Rows[0]["pwd"].ToString();
string args = ip + ":" + port + ":" + useName + ":" + password;
Info.Arguments = args; //设置外部程序的启动参数
Info.WorkingDirectory = file; //设置外部程序工作目录
try
{
System.Diagnostics.Process.Start(Info); //启动外部程序
}
catch
{
MessagingBox mb = new MessagingBox("配置人脸失败区域失败,请检查G2设备配置程序是否在\\G2目录下", Helper.MessageImage.Information, false);
mb.ShowDialog();
}
但愿对你有帮助
以下是我 wpf调用winform的应用程序
string file = string.Format("{0}G2", System.AppDomain.CurrentDomain.BaseDirectory);
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
Info.FileName = "IVM_DVS_G2.exe";//设置外部程序名
string ip=dtDvs.Rows[0]["dvsIp"].ToString();
string port=dtDvs.Rows[0]["port"].ToString();
string useName=dtDvs.Rows[0]["userName"].ToString();
string password=dtDvs.Rows[0]["pwd"].ToString();
string args = ip + ":" + port + ":" + useName + ":" + password;
Info.Arguments = args; //设置外部程序的启动参数
Info.WorkingDirectory = file; //设置外部程序工作目录
try
{
System.Diagnostics.Process.Start(Info); //启动外部程序
}
catch
{
MessagingBox mb = new MessagingBox("配置人脸失败区域失败,请检查G2设备配置程序是否在\\G2目录下", Helper.MessageImage.Information, false);
mb.ShowDialog();
}
但愿对你有帮助
作者: zhang0322yan 发布时间: 2011-12-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28