封装一个进程,并使调用者成为该已封装进程的所有者 [英] shell a process and make the caller form the owner of that shelled process

查看:100
本文介绍了封装一个进程,并使调用者成为该已封装进程的所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请,我想知道如何从我的应用程序中封装一个exe,但同时又如何使调用方表单成为已封装的进程窗口的所有者,如该代码:

Please, I want to know how can I shell an exe from my application but in the same time how can I make the caller form to be the owner of the shelled process window, like that code:

this.AddOwnedForm([the shelled process window]);


谢谢.

推荐答案

您需要获取启动的Process主窗口的句柄.查看Process类,您将找到它.在获取主窗口句柄之前,您可能必须等待流程完全启动.在Process类中也有一个属性.

有了这些,您就可以调用Win32 API函数SetParent,将启动的进程的窗口放到所需的任何容器控件的窗口中,例如Panel.您需要的只是面板控件的窗口句柄,请参见其Handle属性.

您启动的应用程序将短暂显示其窗口,然后结束在您的应用程序窗口内.无法避免这种情况.
You need to get the handle of the main window of the Process you launched. Look into the Process class and you''ll find it. You will probably have to wait for the Process to completely start before you can get the main window handle. There is a property for that also in the Process class.

When you have that, you cal call the Win32 API function SetParent to put the window of the launched process inside the window of whatever container control you want, like a Panel. All you need is your Panel control''s window handle, see its Handle property.

The app you launch will show its window outside of your app for a briefe moment before it ends up inside your application window. There is no way to avoid this.


这篇关于封装一个进程,并使调用者成为该已封装进程的所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆