#define INCL_DOSMODULEMGR USHORT rc = DosFreeModule(ModuleHandle); HMODULE ModuleHandle; /* Module handle */ USHORT rc; /* return code */
Example
This example tries to load module ABCD. The system searches LIBPATH. If unsuccessful, the system tries to to load the module from the program's directory (in case the user forgot to update LIBPATH).
#define INCL_DOSMODULEMGR #define MODULE_NAME "abcd" #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 */ rc = DosLoadModule(LoadError, /* Object name buffer */ sizeof(LoadError), /* Length of object name buffer */ FULL_MODULE_NAME, /* Module name string */ &ModuleHandle); /* Module handle */ rc = DosFreeModule(ModuleHandle); /* Module handle */