Okay.

I have use the kernel32.dll call instead, so the error can be written to a log file.