C#實(shí)現(xiàn)在Form里面內(nèi)嵌dos窗體的方法
本文實(shí)例講述了C#實(shí)現(xiàn)在Form里面內(nèi)嵌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#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C#讀取XML中元素和屬性值的實(shí)現(xiàn)代碼
用C#讀取xml有很多方式,這里我就先使用XmlDocument讀取Xml,用一段代碼遍歷所有元素,并打印student的所有屬性和子節(jié)點(diǎn)的值2013-04-04C# 如何設(shè)置label(標(biāo)簽)控件的背景顏色為透明
這篇文章主要介紹了C# 如何設(shè)置label(標(biāo)簽)控件的背景顏色為透明,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下2020-10-10C#控件picturebox實(shí)現(xiàn)畫圖功能
這篇文章主要為大家詳細(xì)介紹了C#控件picturebox實(shí)現(xiàn)畫圖功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-09C#模擬鏈表數(shù)據(jù)結(jié)構(gòu)的實(shí)例解析
這篇文章主要介紹了C#模擬鏈表數(shù)據(jù)結(jié)構(gòu)的實(shí)例解析,包括隊(duì)雙向鏈表的模擬方法,例子中隊(duì)鏈表的操作也有很好的說明,需要的朋友可以參考下2016-04-04C# 撒列實(shí)現(xiàn)關(guān)鍵字過濾的實(shí)例
C# 撒列實(shí)現(xiàn)關(guān)鍵字過濾的實(shí)例,需要的朋友可以參考一下2013-04-04c#文件的復(fù)制,移動(dòng),創(chuàng)建(實(shí)例代碼)
c#文件的復(fù)制,移動(dòng),創(chuàng)建(實(shí)例代碼),需要的朋友可以參考一下2013-04-04