OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
DLL Entry and Exit Functions

Windows requires that two functions be defined in every

  • DLL: an entry function and an exit function. 16-bit DLLs LibMain is the entry function and WEP (Windows Exit Procedure) is the exit function. LibMain is called by Windows for the first application that calls the DLL, and WEP is called by Windows for the last application that uses the DLL.

32-bit DLLs DllEntryPoint serves as both the entry and exit function. DllEntryPoint is called each time the DLL is loaded or unloaded, each time a process attaches to or detaches from the DLL, and each time a thread within a process is created or destroyed.

Windows calls the entry procedure (LibMain or DllEntryPoint) once, when the library is first loaded. The entry procedure initializes the DLL; this initialization depends almost entirely on the particular DLL function, but might include the following tasks:

  • Unlocking the data segment with UnlockData, if it has been declared as MOVEABLE
  • Setting up global variables for the DLL, if it uses any

There is no need to initialize the heap because the DLL startup code (C0Dx.OBJ) initializes the local heap automatically.