#include #pragma hdrstop #include "%ModuleIdent.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" T%FormIdent* %FormIdent; //--------------------------------------------------------------------------- bool RegisterLibrary() // // Called when the DLL is registered as a COM Server with RegSvr32.exe // Return: // Return false if the library should not be registered as a COM Server // { return true; } bool UnRegisterLibrary() // // Called when the DLL is begin un-registered as a COM Server with RegSvr32.exe // Return: // Return false if the library should not be un-registered as a COM Server // { return true; } TEasyFactoryManager* FindFactoryManager(TDataModule* DataModule) { if (DataModule) { for (int i = 0; i < DataModule->ComponentCount; ++i) { if (dynamic_cast(DataModule->Components[i])) return dynamic_cast(DataModule->Components[i]); } } return NULL; } void InitializeLibrary() // // Called when the library is loaded into a processes memory space or when the // library is loaded for any reason to create the objects to implement the shell // handler or NSE. // // Notes: // Keep any code in this function to a minimum. Do not do any thing that would // cause other DLL's to be loaded within this function // { // Create the DataModule if necessary if (!%FormIdent) %FormIdent = new T%FormIdent(NULL); // Assign the FactoryManager if necessary if (!FactoryManager) { FactoryManager = FindFactoryManager(%FormIdent); for (i = 0; i < %FormIdent->ComponentCount; ++i) { if (!dynamic_cast(%FormIdent->Components[i]) && dynamic_cast(%FormIdent->Components[i])) FactoryManager->ShellHandlerList->Add(%FormIdent->Components[i]); } } } void FinalizeLibrary() // // Called when the library is freed from a processes memory space or when the library // is being released // // Notes: // Keep any code in this function to a minimum. Do not do any thing that would // cause other DLL's to be loaded within this function // { // Factory Manager is a component in the DataModule so the DataModule will free it FactoryManager = NULL; delete %FormIdent; %FormIdent = NULL; }