Function DllLoad() Foundation
Loads a DLL file dynamically during runtime.
DllLoad( <cDllName> [, <cFuncPrefix> ] [, <lSuppressInitExit>] ) --> nDllHandle
The function DllLoad() loads a DLL and returns its numeric DLL handle. When an error occurs, the return value is 0 and the error condition can be determined using the DosError() function.
DllLoad() is used to load 32bit DLL files during runtime of an Xbase++ application. If the DLL is already requested by another process, it is not loaded again. Instead, the current process achieves access to the DLL file by using the DLL handle. The function can load DLL files which are created by Xbase++ as well as system DLLs and other external DLLs. When a DLL is loaded, contained functions can be executed without having them specified to the linker during the creation of the EXE file. DLL functions are executed using the functions DllCall() or DllPrepareCall() and DllExecuteCall().
If other DLLs are linked statically to the loaded DLL, DllLoad() also executes the INIT PROCEDUREs that are programmed in the statically linked DLLs. However, the parameter specified with <cFuncPrefix> is not propagated from the dynamically loaded DLL to statically linked DLLs. Therefore, the parameter <cFuncPrefix> is only valid for the file <cDllName>.
When DLLs are built with Xbase++ and are to be loaded dynamically, all PRG files for that DLL must be compiled with the compiler option /dll:dynamic. If /dll:dynamic is not used, an attempt to load the resulting DLL dynamically will succeed, but DllUnload() will raise a runtime error.
If the name of the DLL file is a full qualified name (including drive and path), this file is loaded when it exists. However, the file name may be specified without drive and path. In this case, the operating system searches for the DLL in the start directory of the application program first. If the DLL exists in this directory, it is loaded. If the DLL is not found, a further search depends on the operating system:
OS/2 searches for the DLL file in all directories listed in the LIBPATH environment variable.
Windows searches directories for the DLL file in the following order: current directory, Windows System directory, Windows directory and finally all directories listed in the PATH environment variable.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.