Compatibility with Existing 16-Bit DLLs

There are certain steps you must take to ensure compatibility with existing 16-bit DLLs. Using the win31compat statement in the thunk script causes the unloading of a 32-bit DLL to be deferred until the containing process terminates. Use this statement to ensure that interprocess loading and freeing procedures, which may have worked with the 16-bit DLL when it was called from 16-bit code, will not cause the 32-bit thunk DLL to be freed prematurely. It also allows the 16-bit library to be freed without execution of the 32-bit DLL's notification routine — an occurrence that could cause reentry into 16-bit code.

You must use the win31compat statement if a 16-bit DLL replaces a DLL that is currently used in a Windows version 3.1 environment or if the DLL runs as part of a graphics device interface (GDI) device driver. You might need use this statement even if your 16-bit DLL does not fit into one of these categories, because it provides extra protection from other DLLs that might be used by your thunk DLL.