Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting Windows dialog error messages to console

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")

like image 846
Zadan Avatar asked Nov 27 '25 13:11

Zadan


1 Answers

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

like image 81
Luke Avatar answered Nov 30 '25 05:11

Luke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!