在运行另一个应用程序之前,以编程方式关闭我的应用程序 [英] Closing programaticaly my app before running an another app
问题描述
你好
运行安装程序时出现问题,我需要很好地关闭作为通知图标的应用程序,我使用Process
类执行此操作,但是MainWindowHandle
返回0,甚至CloseMainWindow
方法也没有"不起作用:(
但是我尝试将FindWindow
与类名和spy ++显示的窗口文本一起使用,并发送WM_CLOSE
消息,它可以工作.
但是我的应用程序中的class_name是不固定的,有什么办法可以修复或解决某个人的问题吗?
谢谢
Hello
I am having a problem when running my installer, i need to close nicely my app that is a notify icon app i use the Process
class to do it but the MainWindowHandle
is returning 0 and even the CloseMainWindow
method doesn''t work :(
but i tried using FindWindow
with the class name and the window text showed by spy++ and send a WM_CLOSE
message and it works.
But the class_name in my app is not fixed, is there any way i can fixed or an workaround somebody?
Thanks
推荐答案
我假设您要从安装程序中关闭应用程序.
在我的头顶上,我看到了两个观点
0)使用 Process.GetProcessesByName [ Process.MainWindowHandle [
I''m assuming you want to close your application from your installer.
Right on top of my head I see two opntions
0) use Process.GetProcessesByName[^] to get the process of your application, and then sendWM_CLOSE
to the window with the handle Process.MainWindowHandle[^]
1) Use IPC, though this seems like overkill.
这篇关于在运行另一个应用程序之前,以编程方式关闭我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!