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
OutputDebugStringAgenerate exceptionDBG_PRINTEXCEPTION_C(Wversion 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
OutputDebugStringto console:and for set this handler need call:
the system implementation of
OutputDebugStringlike here - it really calledRaiseExceptionwith exactly this arguments, only in exception handler insteadMessageBox- code described here.