tags:

views:

162

answers:

1

I've got an unmanaged DLL that is writing log messages to standard output. I'm calling this DLL with P-invokes from a WPF app and I need to get the standard output stream log. I've tried Console.SetOut, but that only seems to capture information written using Console.Write, etc.

Anyone have any ideas? I've found similar questions asked elsewhere but they don't have answers.

A: 

Since you're already calling PInvoke, I guess you wont mind an extra call to SetStdHandle. A similar thread is here http://stackoverflow.com/questions/1579074/redirect-stdoutstderr-on-c-windows-service

Mattias S
I actually did find that after I had asked the question, but sadly it did not work for me. Maybe the fact that this is cross-compiled from MinGW is messing with the output stream somehow. I'll try to get another DLL and see if the build method changes anything.
RandomEngy
Accepting... turns out my cross-compiled MinGW .dll acts differently. I had to have it capture its own output and call a callback I gave it through Pinvoke.
RandomEngy