c#的winform调用外部 exe 作为子窗体,那位达达给个源代码,谢谢 c#的winform调用外部 exe 作为子窗体,那位达达给个源代码,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long 这样很容易出错,出错别怪我 using System.Runtime.InteropServices; [DllImport("user32.dll")] static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] static extern int SetParent(int hWndChild, int hWndNewParent); private void button1_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("calc.exe"); System.Threading.Thread.Sleep(300); SetParent(FindWindow(null, "计算器"), this.Handle.ToInt32()); } System.Diagnostics.Process p = System.Diagnostics.Process.Start(@"Calc"); p.WaitForInputIdle(); SetParent(p.MainWindowHandle, this.Handle); ShowWindowAsync(p.MainWindowHandle, 3);这段程序似乎可以吧其他程序调用进主程序,但是除了calc,notepad这种程序外好像其他都不行,不知道这两个windowsapi怎么用 但是除了calc,notepad这种程序外好像其他都不行,不知道为什么 可能是别的程序有多个窗口,p.MainWindowHandle获得的句柄不对吧那你用FindWindow试试 可能是因为路径的缘故吧,看你的代码里Calc用的似乎是相对路径使用其他程序时写入绝对路径试试 运行exe用这个: System.Diagnostics.Process.Start(@"C:\1.exe"); 记得此板块中有好多人问过好多次,都没有太好的sln. 你把程序放在bin debug 文件夹下.System.Diagnostics.Process.Satrt("xx.exe");试试 用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联!! c# socket结束监听 保留小数点位数问题 求《c#编程思想》。。。 未将对象引用设置到对象的实例。 怎样将图片转成二进制并写入到文本文件中 c# 获取鼠标在屏幕上的位置 急用!!!关于拼音搜索~~~~ 求助 如何查看一个字符串是否包含某个给定的字符串? 如何使用 WebBrowser 控件在 Visual C# 2005 或 Visual C# .NET 中新建 Office 文档 求救!!!!连按SQL出错
using System.Runtime.InteropServices; [DllImport("user32.dll")]
static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")]
static extern int SetParent(int hWndChild, int hWndNewParent); private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
System.Threading.Thread.Sleep(300); SetParent(FindWindow(null, "计算器"), this.Handle.ToInt32());
}
p.WaitForInputIdle(); SetParent(p.MainWindowHandle, this.Handle);
ShowWindowAsync(p.MainWindowHandle, 3);
这段程序似乎可以吧其他程序调用进主程序,但是除了calc,notepad这种程序外好像其他都不行,不知道这两个windows
api怎么用
那你用FindWindow试试
可能是因为路径的缘故吧,看你的代码里Calc用的似乎是相对路径使用其他程序时写入绝对路径试试
System.Diagnostics.Process.Satrt("xx.exe");试试