DosLoadModule (OS/2 1.x)

This call loads a dynamic link module and returns a handle for the module.

Syntax
DosLoadModule (ObjNameBuf, ObjNameBufL, ModuleName, ModuleHandle)

Parameters

 * ObjNameBuf (PSZ) - output: Address of the name of an object that contributed to the failure of DosLoadModule.
 * ObjNameBufL (USHORT) - input: Length, in bytes, of the buffer described by ObjNameBuf.
 * ModuleName (PSZ) - input: Address of the ASCIIZ name string containing the dynamic link module name or the pathname string. The filename extension used for dynamic link libraries is .DLL. When a pathname is provided, the module name may have any extension. The internal module name (the name given in the LIBRARY statement in the .DEF file) must be the same as the filename without the extension.
 * ModuleHandle (PHMODULE) - output: Address of the handle for the dynamic link module.

Return Code

 * rc (USHORT) - return:Return code descriptions are:
 * 0 NO_ERROR
 * 2 ERROR_FILE_NOT_FOUND
 * 3 ERROR_PATH_NOT_FOUND
 * 4 ERROR_TOO_MANY_OPEN_FILES
 * 5 ERROR_ACCESS_DENIED
 * 8 ERROR_NOT_ENOUGH_MEMORY
 * 11 ERROR_BAD_FORMAT
 * 26 ERROR_NOT_DOS_DISK
 * 32 ERROR_SHARING_VIOLATION
 * 33 ERROR_LOCK_VIOLATION
 * 36 ERROR_SHARING_BUFFER_EXCEEDED
 * 95 ERROR_INTERRUPT
 * 108 ERROR_DRIVE_LOCKED
 * 123 ERROR_INVALID_NAME
 * 127 ERROR_PROC_NOT_FOUND
 * 180 ERROR_INVALID_SEGMENT_NUMBER
 * 182 ERROR_INVALID_ORDINAL
 * 190 ERROR_INVALID_MODULETYPE
 * 191 ERROR_INVALID_EXE_SIGNATURE
 * 192 ERROR_EXE_MARKED_INVALID
 * 194 ERROR_ITERATED_DATA_EXCEEDS_64k
 * 195 ERROR_INVALID_MINALLOCSIZE
 * 196 ERROR_DYNLINK_FROM_INVALID_RING
 * 198 ERROR_INVALID_SEGDPL
 * 199 ERROR_AUTODATASEG_EXCEEDS_64k
 * 201 ERROR_RELOC_CHAIN_XEEDS_SEGLIM
 * 206 ERROR_FILENAME_EXCED_RANGE

Remarks
If the file is an OS/2 dynamic link module, it is loaded, and a handle is returned. This handle is used for freeing the dynamic link module with a DosFreeModule request, getting procedure addresses with DosGetProcAddr requests, and getting the fully qualified file name with a DosGetModName request.

DosLoadModule may not be called from a dynamic library initialization routine if the module to be loaded or any module referenced by it contains a dynamic link library initialization routing.

C

 * 1) define INCL_DOSMODULEMGR

USHORT rc = DosLoadModule(ObjNameBuf, ObjNameBufL, ModuleName, ModuleHandle);

PSZ     ObjNameBuf;    /* Address of object name buffer */ USHORT  ObjNameBufL;   /* Length of object name buffer */ PSZ     ModuleName;    /* Address of module name string */ PHMODULE ModuleHandle; /* Address of module handle (returned) */

USHORT  rc;            /* return code */ 

MASM
 EXTRN DosLoadModule:FAR INCL_DOSMODULEMGR  EQU 1

PUSH@ OTHER   ObjNameBuf    ;Object name buffer (returned) PUSH  WORD    ObjNameBufL   ;Length of object name buffer PUSH@ ASCIIZ  ModuleName    ;Module name string PUSH@ WORD    ModuleHandle  ;Module handle (returned) CALL          DosLoadModule

Returns WORD 

Example
This example loads a module. 
 * 1) define INCL_DOSMODULEMGR


 * 1) define MODULE_NAME "abcd"
 * 2) define FULL_MODULE_NAME "\\nifty\\abcd.dll"

CHAR   LoadError[100]; HMODULE ModuleHandle; USHORT rc;

if (DosLoadModule(LoadError,           /* Object name buffer */ sizeof(LoadError),   /* Length of object name buffer */ MODULE_NAME,         /* Module name string */ &ModuleHandle) == 2) /* Module handle */ 