I am using a third party library that uses the function OutputDebugString()
, and when reading the MSDN documentation it seems to indicate that this is for printing to the debugger.
But that is inconvenient in my case, is there a way to read this output if there is no debugger connected?
If it was my LIB, I would prefer the output to go to stdout/stderr whenever the user passes --debug
or similar, but since it's not I am looking for other ways to pass this info to the console (or file) without connecting a debugger.
the
OutputDebugStringA
generate exceptionDBG_PRINTEXCEPTION_C
(W
version in win10 -DBG_PRINTEXCEPTION_WIDE_C
) with 2 arguments - (string length in characters + 1, string pointer) - as result we can handle this exception yourself (system default handler for this exception do this).example handler for redirect
OutputDebugString
to console:and for set this handler need call:
the system implementation of
OutputDebugString
like here - it really calledRaiseException
with exactly this arguments, only in exception handler insteadMessageBox
- code described here.