是否阻止Windows上非交互进程阻止对话框/消息框/挂起GUI? [英] Preventing blocking dialogs/message boxes/hanging GUI from non-interactive processes on Windows?

查看:103
本文介绍了是否阻止Windows上非交互进程阻止对话框/消息框/挂起GUI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在Windows上使用Visual Studio 2005开发C ++应用程序(很多MFC).

We are developing C++ apps (lots of MFC) with Visual Studio 2005 on Windows.

我们的夜间构建和/或单元测试有时会挂起,因为某些应用程序或辅助工具的某些部分会在被构建击中的极端情况下打开一个消息框.

From time to time it happens that our nightly builds and/or unit tests hang because some part of some app or helper tool opens a message box in a corner case that is hit by the build.

由于自动化的东西是通过Windows服务运行的,没有附加任何桌面会话,因此显然没有人可以确认-甚至无法读取-GUI消息.

Since the automated stuff is run (by a Windows Service) without any desktop session attached, obviously no-one can confirm - or even read - the GUI messages.

有什么方法可以使Windows阻止应用程序打开对话框?还是某个工具可以监视服务会话,该服务会话会自动杀死打开对话框的任何应用程序?

Is there any way to have Windows prevent apps from opening dialogs? Or maybe a tool that watches a service session that auto-kills any app that opens a dialog box?

我认为大多数情况下,应用显示意外的弹出消息,最终将调用user32.dll中的MessageBox*函数之一,并且可能神奇地"使这些函数失败某些登录会话? (只是个疯狂的主意.)

I'm thinking that most cases where apps display unexpected popup-messages, it will end up calling one of the MessageBox* functions from user32.dll and it might be just possible to "magically" have these functions fail for a certain login-session? (Just a wild idea.)

显然,正确"的解决方案是使内容不打开任何对话框,但是使用第三方工具并不总是可能的,并且使用我们的工具进行失败单元测试会更好告诉我测试非法"打开了一个消息框,而不是进行悬挂单元测试.

Obviously the "right" fix is to have stuff not opening any dialogs, but with 3rd party tools it ain't always possible and with our tools it would be nicer to have a failing unit test that tells me the test "illegally" opened a message box than have a hanging unit test.

(旁注:我们在单元测试中使用Boost.Test,在自动构建脚本中使用FinalBuilder.)

(Side notes: We're using Boost.Test for our unit tests and FinalBuilder for our automatic build scripts.)

注意:删除了原始标签[Continuous-integration build-automation自动测试],并重新表述了问题,使其更加以过程为中心.

推荐答案

您可以在每个进程中加载​​DLL,这将钩接到MessageBoxA和MessageBoxW上.您可以手动执行此操作,也可以通过Detours库执行此操作.然后,您可以使它直接返回而无需调用真实函数,或者甚至可以实施某种形式的日志记录以将错误通知给CI.

You can load a DLL in each of the processes which puts a hook onto MessageBoxA and MessageBoxW. You can either do this manually or via the Detours library. You can then either have it return straight away without calling the real function or you could even implement some form of logging to notify your CI of the error.

这篇关于是否阻止Windows上非交互进程阻止对话框/消息框/挂起GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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