Redirecting Windows dialog error messages to console

淺唱寂寞╮ 提交于 2019-12-11 02:48:25

问题


Does anyone know how to redirect/capture modal Windows error dialogs? This is really problematic for non-interactive, command-line programs that are merely trying to run a program and capture the exit code and stdout/stderr output.

The most recent instance of this issue is a modal Windows dialog that has the following form:

The program can't start because <foo.dll&gt is missing from your computer. Try reinstalling the program to fix this problem.

(Where the title of the modal GUI window is "System error")


回答1:


These system error dialogs can be suppressed with SetErrorMode(). In that case, CreateProcess() should fail and GetLastError() should give you the corresponding error code.



来源:https://stackoverflow.com/questions/8024579/redirecting-windows-dialog-error-messages-to-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!