zoukankan      html  css  js  c++  java
  • C#窗体内嵌外部程序(cmd.exe)的显示 转 武胜

    C#窗体内嵌外部程序(cmd.exe)的显示

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

            }

  • 相关阅读:
    毕设进度28
    任务27
    任务26
    任务25
    任务24
    第二次冲刺
    课堂作业-搜狗输入法
    课堂作业-寻找水王
    博客花园典型用户和场景
    第十天
  • 原文地址:https://www.cnblogs.com/zeroone/p/2478491.html
Copyright © 2011-2022 走看看