Added some SetLastError()s to get correct error codes in Win32.

```GetLastError()``` might return a wrong code if the error code is already set by the caller.