title: Proper handling of GetLastError (and others) in a multithreaded context
body: <p>Is it correct to assume that GetLastError (and variants) are per-thread or is it per-process?  The problems if it is per-process are somewhat obvious in multithreaded apps because there is no way to guarentee that no other Win32 calls were made between your failed call and GetLastError.  Sometimes the value of GetLastError is important. </p>
  
  <p>For example, AcceptEx will return FALSE (failure) if you are using IO completion ports.  WSAGetLastError (similar to GetLastError) will return ERROR_IO_PENDING to inform you that it is pended and the failure is not due to something else.  The problem is that dozens of ofther calls can be in flight and overwrite this value. </p>
  
  <p>Are these calls thread specific or process specific?  If process specific then how do you handle this correctly?</p>