zoukankan      html  css  js  c++  java
  • 把第三方的exe程序嵌入C#界面上

    public partial class eTerm_Form : WinFormsUI.Docking.DockContent
    {
    public eTerm_Form()
    {
    InitializeComponent();
    }

    Process process = null;
    IntPtr appWin;

    [DllImport("user32.dll", SetLastError = true)]
    private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [DllImport("user32.dll", SetLastError = true)]
    private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll", SetLastError = true)]
    private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags);
    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);

    private void eTerm_Form_Resize(object sender, EventArgs e)
    {
    if (this.appWin != IntPtr.Zero)
    MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
    }

    private void eTerm_Form_Load(object sender, EventArgs e)
    {
    try
    {
    process = System.Diagnostics.Process.Start(@”E:MyProjectNewSkyrickieManageSkyrickieManageShenZhen.skyrickie.SkyrickieManagebinDebugSkyrickieManage.exe”);
    process.WaitForInputIdle();
    appWin = FindWindow(null, “skyrickie个人管理系统登录”);
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, “Error”,MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

    SetParent(appWin, this.Handle);
    MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
    }

    private void eTerm_Form_FormClosing(object sender, FormClosingEventArgs e)
    {
    try
    {
    if (!process.HasExited)
    process.Kill();
    }
    catch
    {
    }
    }
    }

  • 相关阅读:
    最新可靠好用的DNS服务器地址汇总
    使用 MNIST 图像识别数据集
    MNIST手写数字数据库
    OCR学习及tesseract的一些测试
    Improving the quality of the output
    解决Web部署 svg/woff/woff2字体 404错误
    Bootstrap 网格系统(Grid System)的工作原理
    手写数字样本库的下载地址
    Tesseract-OCR 训练过程 V3.02
    tesseract-orc 合并识别结果
  • 原文地址:https://www.cnblogs.com/skyay/p/4216201.html
Copyright © 2011-2022 走看看