Initialization

<< Click to Display Table of Contents >>

Navigation:  Introduction to Borland Database Engine >

Initialization

Previous pageReturn to chapter overviewNext page

You should be aware of how the Borland Database Engine (BDE) is loaded at startup. This is important if you have other versions or multiple copies of BDE on your system.

The search algorithm for loading the BDE dll, Idapi32.dll, is:

1.Current directory (might be different from applications startup directory!).
If not found, then:

2.BDE path registry entry:
HKEY_LOCAL_MACHINE/ SOFTWARE/ Borland/
Database Engine/ DLLPATH/xxxxx
If not found, then:

3.LoadLibrary algorithm. Application’s startup directory.
1. Current directory. If not found, then
2. System directory. If not found, then
3. Windows directory. If not found, then
4. PATH environment

Loading driver dll's follows the same pattern, except the first directory to be searched is the directory where Idapi32.dll loaded (replaces step1).

Note:Loading from a current directory of an application might be useful in certain situations, but it effectively prevents other BDE applications from running simultaneously, because they would likely find another Idapi32.dll and fail at initialization time (DbiInit) with DBIERR_MULTIPLEIDAPI.

Shared memory loading addresses for DLLs

BDE reserves certain preferred memory addresses for use by its DLLs. In most cases, if a DLL cannot be loaded at its preferred address, it will load at some other address determined by the system.

However the DLLs listed below must be loaded at the same preferred address in all applications using BDE. The native BDE drivers reserve the following addresses:

BDE DLLs

Addresses

IDAPI32.DLL

0x4BDE0000

IDPDX32.DLL

0x4CDE0000

IDDBAS32.DLL

0x4DDE0000

IDASCI32.DLL

0x4EDE0000

If these memory locations are already in use by other applications, the BDE DLLs assigned to those locations might not load, in which case an error message would be generated:

If Idapi32.dll cannot load because the address space is already used, then DBIERR_CANTLOADIDAPI is returned.

If any of the shared drivers cannot load because of a conflict, then DBIERR_CANTLOADLIBRARY is returned with the name of the driver.

SQL drivers are not shared and do not require fixed loading addresses.

Multiple initializations and exits

You may make multiple calls of DbiInit from within the same process, but each DbiInit should be paired with a corresponding DbiExit.

Error recovery

In the event of a fatal application error, it is recommended to use DbiExit to shut down BDE cleanly.

In the event of a fatal BDE error, it is recommended to close down all applications using BDE.