|December 20, 2000 No. 96|
Search Sequence for Locating DLL's
One of the questions that arises when using external libraries in conjunction with NPL is how does NPL find the library? DLL's used with the /X option of NPL are not normally registered, but rather are found by a Microsoft API LoadLibrary call, which uses the standard Windows hunt order for directories to search.
If the filename has a specified path on it, that path is the only place that is searched. If the DLL is not found at the location specified, the search is abandoned and an error message is returned.
If no path is specified, Windows looks in the following places, in this order:
1. The directory from which the application (RTIWIN32.EXE) loaded [32-bit only].
2. The current directory, for example the "start in" directory in a shortcut.
3. For Windows 95/98/ME: The Windows system directory (\windows\system\)
For Windows NT/2000: The 32-bit Windows system directory (\winnt\system32\) first then the 16-bit Windows system directory (\winnt\system\)
4. The Windows directory (\windows or \winnt)
5. The directories that are listed in the PATH environment variable
If the named DLL is not found anywhere in the above search sequence, an error message is generated.
Caution: the following has been a major source of confusion.
Some primary DLLs used by NPL will make calls to a secondary DLL. The first DLL has a dependency on the second DLL. Windows checks for any dependencies and tries to find all other DLLs that the initial DLL is dependent upon. If any of those secondary DLLs can't be found, an error message is returned that the primary DLL is missing when in fact one of the secondary DLLs is missing. There is no facility to determine which DLL is missing, only that one is. Windows assumes that the DLL failed to load because the first DLL could not be found.
So, if the DLL being loaded is in the right location and the DLL not found message is still generated, consider checking for other DLLs that the primary DLL may require. For example:
NDM (Niakwa Data Manager) is distributed with NDMBTR32.DLL which has a dependency on WBTRV32.DLL supplied by Btrieve/Pervasive. The RunTime is started using the /xNDMBTR32.DLL command line option, Windows finds the first DLL and checks for dependencies. Finding that NDMBTR32.DLL requires WBTRV32.DLL, Windows tries to locate WBTRV32.DLL. If it is not there, Windows will report the error "External Library NDMBTR32.DLL not found", when in fact it's WBTRV32.DLL that hasn't been found.