17.6. DLL Entry Points

A DLL can optionally contain a special function called the entry-point function. This function is called automatically each time a new process loads or unloads the DLL and each time an attached process creates or destroys a thread. Applications do not care whether or not a DLL contains an entry-point function. You do not have to modify either load-time or run-time linked applications to accommodate an entry point.

Entry-point functions exist primarily so that DLLs can properly initialize variables or data structures that are private to the processes or threads using the DLL. For example, if the DLL needs to maintain a separate copy of a certain data structure for each process that attaches, the entry point function is the ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.