c#内嵌脚本语言_C#实现在Form里面内嵌dos窗体的方法
发布日期:2021-06-24 13:27:52 浏览次数:2 分类:技术文章

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

这篇文章主要介绍了C#实现在Form里面内嵌dos窗体的方法,涉及C#针对Form窗体的设置及使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了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#程序设计有所帮助。

转载地址:https://blog.csdn.net/weixin_33178459/article/details/112842034 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:python的内存机制是什么意思_python 内存机制
下一篇:后台弹出界面 常驻通知_如何关闭拼多多的各种广告通知,但不必删除它?这篇干货要收好!...

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月14日 03时27分55秒