C#窗体内嵌外部程序(cmd.exe)的显示
2012-04-07 10:40
246 查看
[DllImport("User32.dll ", EntryPoint = "SetParent")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll ", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
private void button3_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe ";
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;//加上这句效果更好
p.Start();
System.Threading.Thread.Sleep(100);//加上,100如果效果没有就继续加大
SetParent(p.MainWindowHandle, panel1.Handle); //panel1.Handle为要显示外部程序的容器
ShowWindow(p.MainWindowHandle, 3);
}
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll ", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
private void button3_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe ";
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;//加上这句效果更好
p.Start();
System.Threading.Thread.Sleep(100);//加上,100如果效果没有就继续加大
SetParent(p.MainWindowHandle, panel1.Handle); //panel1.Handle为要显示外部程序的容器
ShowWindow(p.MainWindowHandle, 3);
}
相关文章推荐
- C#窗体内嵌外部程序(cmd.exe)的显示 转
- C#窗体内嵌外部程序(cmd.exe)的显示(转载)
- C#窗体内嵌外部程序(cmd.exe)的显示
- C#窗体内嵌外部程序(cmd.exe)的显示【转载】
- C#调用cmd.exe程序和外部程序
- C#调用cmd.exe程序和外部程序
- 窗体内嵌外部程序的显示,获取控件的图片
- C#调用cmd.exe程序和外部程序
- C#调用cmd.exe程序和外部程序
- C#调用外部exe作为子窗体或UI? VC++如何实现呢呢?...札记plus
- C#将exe运行程序嵌入到自己的winform窗体中
- c#窗体编程之建立时钟程序显示当前时间
- C# 屏幕监控 自动截屏程序 主窗体隐藏,仅在进程中显示
- win10的cmd中显示:telnet不是内部或外部命令也不是可运行的程序或批处理?
- C#将exe运行程序嵌入到自己的winform窗体中
- wince程序窗体 居中显示[C#]
- C# 运行cmd.exe执行ffmpeg进行视频转码,程序无法关闭
- 一个程序在后台运行(即隐藏了窗体), 如果再次点击exe时则显示出已运行的程序窗体。
- 外部启动c#窗体程序传参问题
- c#调用外部exe程序