Fix build with MinGW, part 1 of 2.

MinGW's secure API is missing sscanf_s and swscanf_s.
Fix build with MinGW, part 2 of 2.

Some MinGW toolchains still lack SetThreadErrorMode, so
revert to using SetErrorMode like the 2013 dispatcher did.