C#实现在Form里面内嵌dos窗体的方法
程序员文章站
2022-07-22 13:09:41
本文实例讲述了c#实现在form里面内嵌dos窗体的方法。分享给大家供大家参考。具体如下:
using system;
using system.windows...
本文实例讲述了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#程序设计有所帮助。
上一篇: 腌制糖蒜的正确方法,它的功效与作用有哪些