--- a/pthread_win32_attach_detach_np.c
+++ b/pthread_win32_attach_detach_np.c
@@ -67,6 +67,7 @@
   /*
    * Load QUSEREX.DLL and try to get address of QueueUserAPCEx
    */
+  SetDllDirectory(""); /* Don't search in current directory */
   ptw32_h_quserex = LoadLibrary (TEXT ("QUSEREX.DLL"));
 
   if (ptw32_h_quserex != NULL)
@@ -111,6 +112,8 @@
 	  ptw32_h_quserex = 0;
 	}
     }
+
+  SetDllDirectory(NULL); /* Reset DLL search path to default */
 
   if (ptw32_h_quserex)
     {