RandomEngy
RandomEngy

Reputation: 15413

Getting stdout when p-invoking to unmanaged DLL?

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.

Upvotes: 8

Views: 4503

Answers (1)

Mattias S
Mattias S

Reputation: 4808

Since you're already calling PInvoke, I guess you wont mind an extra call to SetStdHandle. A similar thread is here Redirect stdout+stderr on a C# Windows service

Upvotes: 4

Related Questions