Patch from Gisle Vanem to improve win32 support