use 'which' that doesn't bail out
get OS on W32
only set p_thread(0) is we don't have PTW32_HANDLE_T

compat with MinGW
added check for ptw32_handle_t type