I have a problem similar to the one here where I have a P/Invoked third party DLL that writes to stdout and I'd like to prevent that. In my case instead of redirecting it to a log file I'd like to ignore it.
Is it correct to use SetStdHandle(StdOuputHandle, IntPtr.Zero)
to do this?
In my testing this seems to work but I haven't been able to find any documentation that states that passing NULL is permitted and will have the desired effect.
The GetStdHandle documentation states:
If an application does not have associated standard handles, such as a service running on an interactive desktop, and has not redirected them, the return value is NULL.
but this is far from explicit documentation that NULL means disassociate the existing standard handle in SetStdHandle.