C#实现在Form里面内嵌dos窗体的方法
2015-09-04 12:57
671 查看
本文实例讲述了C#实现在Form里面内嵌dos窗体的方法。分享给大家供大家参考。具体如下:
using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; namespace cmdForm { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = "cmd.exe ";//notepad.exe p.Start(); System.Threading.Thread.Sleep(100); SetParent(p.MainWindowHandle, this.Handle); ShowWindow(p.MainWindowHandle, 3); } [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); } }
希望本文所述对大家的C#程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- 5个常见可用性错误和解决方案
- c#调用COM组件
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#通用邮件发送类分享
- C#中this的用法集锦
- C#.NET获取拨号连接的宽带连接方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析
- C#生成饼形图及添加文字说明实例代码
- C#判等对象是否相等的方法汇总
- C#简单的向量用法实例教程
- C#实现基于链表的内存记事本实例
- C#托管堆对象实例包含内容分析
- C#实现按照指定长度在数字前补0方法小结