Redirecting ansicon to NUL would still write to the console, as NUL is regarded as a character device. Export IsConsoleHandle and use that instead of _isatty.
Create an import library containing the necessary CRT functions and link with that, rather than the compiler's own version.