In case rbb's forward was too cryptic, I think the chief problem is that file_io/unix/mktemp.c:gettemp() (which is not generally used on Unix since APR uses mkstemp() there) does a direct comparison with APR_EEXIST instead of using APR_STATUS_IS_EEXIST. So on Windows, APR winds up returning a "file already exists" error instead of catching it.
It is also perhaps impolite to reseed the libc random number generator. And using GetTempFileName() might be more efficient in general. (All of this is from c.a.t.'s reports and my own deductions about the code; I don't have a Windows development environment to test hypotheses with.)