| |
t e m p o r a l |
d o o r w a y |
|||||||||
Using A Data Module In A DLL |
|||||||||||
|
Data modules are a natural complement to conventional DLLs and to COM objects, especially those based on Active Server Library DLLs. Setting up a basic DLL is simple and is covered elsewhere. But the way in which the data module should be instantiated in the DLL is not well documented. The following code makes the method clear:
First, if the data module is to be instantiated only once for the life of the DLL, it should be created in the DllEntryPoint function, which is called each time the DLL is attached to a process. To prevent the data module from being created more than once, a check of the data module global pointer is made. If it is is NULL, then the data module has not been instantiated. Alternatively, you can use this method:
This method simply uses a static local variable to keep track of the first time the function is entered. In both cases, it is necessary to call Application->Initialize() to ensure that the DLL (this is the DLL application handle, not that of the caller) is prepared to create the data module. Then CreateForm is used to create the data module, and the application is made the owner so that the data module will be automatically destroyed when the DLL is unloaded. Simple, right? |
|||||||||||
|
Copyright © 2004 by Mark
Cashman (unless otherwise indicated), All Rights Reserved
|