OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
The TModule Object

An instance of the TModule class serves as the object-oriented interface for an ObjectWindows DLL. TModule member functions provide support for window and memory management, and process errors.

The following code example shows the declaration and initialization of a TModule object. This example is conditionalized so that either 16-bit

  • (LibMain) or 32-bit (DllEntryPoint) DLLs can use the same source file.
    static TModule *ResMod;
    #if defined(__WIN32__)
    bool WINAPI
    DllEntryPoint(HINSTANCE instance, uint32 /*flag*/, LPVOID)
    #else // !defined(__WIN32__)
    int
    FAR PASCAL
    LibMain(HINSTANCE instance, uint16 /*wDataSeg*/, uint16 /*cbHeapSize*/, char far* /*cmdLine*/)
    #endif
    {
    // We are using the DLL and want to use the DLL's resources
    //
    if (!ResMod)
    ResMod = new TModule(0,instance);
    return true;
    }
    int WINAPI DllEntryPoint(HINSTANCE hInstance, uint32 reason, LPVOID)
    Definition libmain.cpp:51
    Within the entry point function the TModule object ResMod is initialized with the instance handle of the DLL. If the module is not loaded an exception is thrown.

If your DLL requires additional initialization and cleanup, you can perform this processing in your LibMain, DllEntryPoint, or WEP functions. A better method, though, is to derive a TModule class, define data members for data global to your DLL within the class, and perform the required initialization and cleanup in its constructor and destructor.

After you have compiled and linked your DLL, use IMPLIB to generate an import library for your DLL. This import library will list all exported member functions from your shared classes as well as any ordinary functions you have exported.