DosLoadModule
Appearance
DosLoadModule
Syntax
rc = DosLoadModule( pszObjectNameBuffer, ulObjectNameBufferLength, pszModuleName, phMod );
Parameters
- PSZ pszObjectNameBuffer (output)
- Address to a buffer into which in case of failure the name of the object that caused the failure is placed.
- ULONG ulObjectNameBufferLength (input)
- Size of the pszObjectNameBuffer.
- PSZ pszModuleName (input)
- Name of the DLL to be loaded.
- PHMODULE phMod (output)
- Pointer to the handle for the module.
Returns
- APIRET rc
- Indicates if any error occured.
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_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT |
206 | ERROR_FILENAME_EXCED_RANGE |
295 | ERROR_INIT_ROUTINE_FAILED |
Include Info
#define INCL_DOSMODULEMGR #include <os2.h>
Usage Explanation
DosLoadModule tries to load a dynamic link module. If the module is an OS/2 dynamic link module then the module is loaded and a handle to the module is returned.
Relevant Structures
Gotchas
pszModuleName MUST NOT contain the .DLL extension if the DLL is to be loaded from the LIBPATH. On the other hand, if the DLL has to be loaded from a specific directory (i.e. not from the LIBPATH) then the .DLL extension is needed.
Sample Code
HMODULE hmod; APIRET rc = 0; UCHAR szErrorName[CCHMAXPATH]; /* CCHMAXPATH defined in bsedos.h */ /* Load module. */ /* Try in same directory. */ rc=DosLoadModule(szErrorName, CCHMAXPATH-1, ".\\mydll.dll", &hmod); if (rc) { /* Failure? */ printf("Error in %s. Cannot load the DLL. DosLoadModule returned %d.\n", szErrorName, rc); return(-1); } /* Query process addresses with DosQueryProcAddr() */ /* Free module with DosFreeModule(hmod) */