SOM_ClassLibrary

From EDM2
Jump to: navigation, search

This macro identifies the file name of the DLL for a SOM class library in a Windows LibMain function.

Syntax

string    libname.dll;
SOM_ClassLibrary(libname.dll);

Parameters

libname.dll (string)
The name of the file containing the DLL (as the name would appear in a Windows LoadLibrary call.

Return Code

Remarks

Each Windows SOM class library must supply a Windows LibMain function. In LibMain, this macro identifies both the actual file name of the library as it would appear in a Windows LoadLibrary call and the location of the library's SOMInitModule function. This information is passed to the SOM Kernel, which in turn registers the library and schedules the execution of the SOMInitModule function. This macro can also be used in OS/2 class libraries within the context of a DLL "init/term" function.

Typically, the SOM Kernel invokes the SOMInitModule function of each statically loaded class library during the execution of the somMainProgram function in the using application. For dynamically loaded class libraries, SOMInitModule is invoked immediately upon completion of the library's LibMain (or an OS/2 DLL "init/term") function.

Because this macro expands to reference the SOMInitModule function, either a declaration of the SOMInitModule function, or the function itself, should precede the appearance of SOM_ClassLibrary in the current compilation unit, as shown in the Example below).

Example Code

The Example illustrates the use of the SOM_ClassLibrary macro in a Windows LibMain function

#include <som.h>
SOMEXTERN void SOMLINK SOMInitModule (long majorVersion,
                                      long minorVersion,
                                      string className);
#include <windows.h>
int CALLBACK LibMain (HINSTANCE inst,
                      WORD ds,
                      WORD Heapsize,
                      LPSTR cmdLine)
{
    SOM_IgnoreWarning (inst);
    SOM_ignoreWarning (ds);
    SOM_IgnoreWarning (heapSize);
    SOM_IgnoreWarning (cmdLine);

SOM_ClassLibrary ("xyz.dll");
    return 1;  /* Indicate success to loader */
}

Related

Macro

  • SOM_MainProgram

Functions

  • somMainProgram