博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#窗体内嵌外部程序(cmd.exe)的显示 转
阅读量:6976 次
发布时间:2019-06-27

本文共 630 字,大约阅读时间需要 2 分钟。

[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);

        }

转载地址:http://doupl.baihongyu.com/

你可能感兴趣的文章
LVM逻辑卷的缩减与删除,LVM逻辑卷快照,btrfs文件系统,网络管理
查看>>
git命令
查看>>
grails 常用修改
查看>>
Java 匿名类也能使用构造函数
查看>>
nginx系列:nginx反向缓存代理详解
查看>>
点击通知栏后打开Activity,并传参
查看>>
检查是否支持 SO_REUSEPORT
查看>>
Spring MVC配置
查看>>
JDBC连接各种数据库方法
查看>>
国际版Azure搭建Windows多种类型×××_三.配置SSTP ×××连接服务
查看>>
fullPage教程 -- 整屏滚动效果插件 fullpage详解
查看>>
Python 安装 xlsx模块
查看>>
周鸿祎在360新员工入职培训上的讲话
查看>>
鸟哥学习笔记---网络安全基础
查看>>
The Life Cycle of a Servlet
查看>>
spring mvc文件上传小例子
查看>>
spring cloud快速搭建
查看>>
PL/SQL --> INSTEAD OF 触发器
查看>>
XShell连接Deepin
查看>>
ecshop 商品颜色尺寸仿淘宝选择功能教程(2.7.0版本)
查看>>