C++/Win32 枚举属于我的进程的窗口 &关闭它们
我有一个 Windows 应用程序,其中嵌入了一个 Web 浏览器(Internet Explorer)。可以通过 IPC 从另一个进程关闭该应用程序。除了嵌入式 Web 浏览器可能显示弹出对话框窗口(例如,在保存内容期间)的情况外,它工作得很好。在这种情况下,当我的应用程序尝试通过 IPC 关闭外部请求时,它会崩溃。 (在内部,它只是将 WM_CLOSE 消息发送给自身。)
鉴于此,我想提出一种方法来枚举属于我的进程的所有窗口,并在关闭我的进程本身之前先关闭它们。问题是,如何枚举属于我的进程的所有窗口以关闭它们?
I have a Windows app that houses a web browser (Internet explorer) embedded in it. The app can be closed from another process by means of IPC. It works just fine except the situation when the embedded web browser may be displaying a pop-up dialog window (say, during saving of contents). In that case my app crashes when it tries to close from an outside request via IPC. (Internally it simply posts the WM_CLOSE message to itself.)
In light of that I thought to come up with a way to enumerate all windows that belong to my process and close them first before closing my process itself. The question is, how do you enumerate all windows belonging to my process for the purpose of closing them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我想我自己得到了。如果有人感兴趣的话,这是:
OK, I guess I got it myself. Here's if someone is interested:
当您希望进程退出时,只需调用
ExitProcess
即可。无论当时打开什么窗口,它们都会消失。When you want your process to exit, just call
ExitProcess
. It doesn't matter what windows might be open at the time, they all go away.