结束.exe进程(VB.NET) [英] End .exe process (VB.NET)

查看:92
本文介绍了结束.exe进程(VB.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体应用程序(appLoader.exe),我曾在那里使用另一个.exe文件(TestApp.exe)。当我封装TestApp.exe文件时,应用程序将运行,但是当我关闭appLoader.exe时,另一个应用程序仍将运行。如果关闭appLoader.exe,如何结束TestApp.exe的进程?



我尝试过:



到目前为止,我只进行shell编码打开TestApp.exe

I have a Windows Form Application (appLoader.exe) where I used to Shell another .exe file (TestApp.exe). When I Shell the TestApp.exe file, the application will run but when I closed the appLoader.exe, the other app will still running. How to end the process of the TestApp.exe if the appLoader.exe is closed?

What I have tried:

So far, I only do the shell coding to open the TestApp.exe

Shell("TestApp.exe")

推荐答案

使用 Shell ,而不是向后兼容VB6。 us / library / 53ezey2s%28v = vs.110%29.aspx> Process.Start [ ^ ]。这将返回流程 [ ^ ]对象,可用于监视外部进程。



如果外部应用程序有用户界面,则可以调用CloseMainWindow [ ^ ]关闭应用程序优雅。否则,您可以致电杀死 [ ^ ]立即终止申请。但是,请注意,这不会使应用程序有机会正常关闭,并可能导致数据丢失。
Rather than using Shell, which is only provided for backwards-compatibility with VB6, use Process.Start[^]. That will return a Process[^] object which you can use to monitor the external process.

If the external application has a user interface, you can then call CloseMainWindow[^] to close the application gracefully. Otherwise, you can call Kill[^] to immediately terminate the application. However, be aware that this will not give the application a chance to shut down properly, and may result in data loss.


这篇关于结束.exe进程(VB.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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