When writing DLL functions that will be called from an application, keep these things in mind:
- Make calls to 16-bit DLL functions far calls, and make pointers specified as parameters and return values far pointers. You need to do this because a 16-bit DLL has different code and data segments than the calling application. This is not necessary for 32-bit DLLs. Use the _FAR macro to make your code portable between platforms.
- Static data defined in a 16-bit DLL is global to all calling applications because 16-bit DLLs have one data segment that all 16-bit DLL instances share. Global data set by one caller can be accessed by another. If you need data to be private for a given caller of a 16-bit DLL, you need to dynamically allocate and manage the data yourself on a per-task basis. For 32-bit DLLs, static data is private for each process, except under Win32s.
See Also