|
|
Delphi |
To link to OrcFxAPI using Delphi you need to use the import unit OrcFxAPI.pas. This unit contains declarations of the DLL's data structures, types, constants and functions.
By default, using OrcFxAPI.pas will lead to your application linking to the OrcFxAPI DLL by means of load-time dynamic linking. As an alternative you can opt to use run-time dynamic linking. To do so you must define the conditional ExplicitLinkOrcFxAPI. In addition you will need to take charge of loading the DLL, typically with a call to LoadLibrary. Before calling any OrcFxAPI functions you must make a call to InitializeOrcFxAPI passing the module handle of the OrcFxAPI DLL.
Note that there are special linking requirements for external function DLLs.
When using load-time dynamic linking, the loader will use the DLL search order to locate the OrcFxAPI DLL. Older versions of OrcaFlex installed the OrcFxAPI DLL to the Windows system directory. Starting with OrcaFlex 9.6, the DLL is no longer installed to the Windows system directory. Instead the installation program places the DLL under the OrcaFlex installation directory, in directories named OrcFxAPI\Win32 and OrcFxAPI\Win64. The Win32 directory contains 32 bit versions of DLL and LIB files; the Win64 directory contains the 64 bit files.
In order for your program to be able to load the OrcFxAPI DLL, it follows therefore that it must be found in the DLL search order. The recommended way to meet this requirement is to place the OrcaFlex DLL in the same directory as your program's executable file.
For run-time dynamic linking, you are responsible for specifying the location of the DLL. Either rely on the DLL search order by passing 'OrcFxAPI.dll' to LoadLibrary, or specify the full path to the DLL.
Starting with version 11.0, the OrcFxAPI DLL's dependencies must be located alongside the DLL. These dependencies are packaged as a Windows assembly, installed to directories named OrcFxAPI\Win32\lib32 and OrcFxAPI\Win64\lib64. If you copy the OrcFxAPI DLL to a location away from its installation directory (e.g. to your program's executable directory), then you must also copy the appropriate dependencies (lib32 or lib64 depending on the bitness of the DLL) to the same location.
If the OrcFxAPI DLL is unloaded other than during process termination, then you should call C_FinaliseLibrary immediately before the DLL is unloaded. Note that you must not call C_FinaliseLibrary while inside a DllMain function.