防止在无人值守构建中出现对话框
我想知道是否有一种万无一失的方法可以在 Windows 上运行程序,以便我保证不显示任何类型的交互式对话框。
我尝试过注册表ErrorMode hack,调用_CrtSetReportMode()等,但它们都有漏洞或者需要你修改程序。
我需要一种方法来运行任意程序,并实际上强制Windows执行它们,这样它们就不可能打开窗口。 如果程序尝试打开一个窗口,那么崩溃是完全可以的。
将程序作为服务运行可以解决问题吗?
I was wondering is there is a fool-proof way to run a program on windows such that I'm guaranteed that no interactive dialogs of any kind are displayed.
I've tried the registry ErrorMode hack, calling _CrtSetReportMode(), etc., but they all have holes in them or require you to modify the program.
I need a way to run an arbitrary program and practically force Windows to execute them such that there is no possibility for them to open a window. It is perfectly ok for the program to crash if it attempts to open a window.
Would running the program as a service solve the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道任何其他可能有效的方法。 作为服务运行也无法解决问题,因为对话框将显示在服务的桌面上,而您通常无权访问该桌面。
I'm not aware of any other ways that might possibly work. Running as a service won't solve the problem either as the dialog will be displayed on the service's desktop, which you generally don't have access to.
您可以使用诸如 Detours 之类的库来拦截对可能显示对话框的函数的所有调用框(实际上这可能是 user32.dll 中的几乎所有内容)。
You could use a library such as Detours to intercept all calls to functions that might display a dialog box (this might in fact be nearly everything in
user32.dll
).