It would be pretty easy to do this in Win32 using the Detours Library . You would look at all the WriteFile calls and see if they go to standard outputs. You can also look at console output functions (e.g. WriteConsoleOutput), but they are rarely used, so you probably don't have to worry about using most programs.
Offline I don’t remember whether workarounds support using .NET languages or not. If this is not the case, I suppose you can still use it through P / Invoke, but I don’t think it would be at all ...
Edit: There are various similar (free) libraries. For example, Jeffrey Richter’s book, Advanced Windows, uses one that should work for this purpose. A quick glance shows that its current Windows using C / C ++ still includes the section "Enabling the DLL and Connecting to the API". This probably includes (and an updated version) the same code, which should be sufficient for this kind of work.
source share