> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using ABBYY FlexiCapture SDK in Delphi

This section deals with certain peculiarities of using ABBYY FlexiCapture SDK in Delphi.

## Creating the Object Pascal Wrapper Unit

In order to use ABBYY FlexiCapture 12 SDK in Delphi, it is necessary to create the Object Pascal wrapper unit for the type library (the FCEngine\_TLB.pas file). To generate the wrapper:

1. Run command prompt (cmd.exe) and go to the folder where the ABBYY FlexiCapture 12 SDK type library (FCEngine.tlb) is located.
2. Run the **tlibimp** utility with the following parameters:

   ```bat theme={null}
   tlibimp -O- -Cd- -C- -P+ -Pt+ FCEngine.tlb
   ```

This will generate the FCEngine\_TLB.pas file.

1. Add FCEngine\_TLB.pas to your project.

You need to regenerate FCEngine\_TLB.pas each time you receive an updated version of ABBYY FlexiCapture 12 SDK.

## Using Engine loaders in Delphi 7

There is also an alternative way of using ABBYY FlexiCapture SDK in Delphi 7, for which you will not need to create the wrapper manually as described above. But this method is only suitable if you load the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object in your application using the [Engine loaders](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engineloaders-overview.md).

1. Open your project and choose **Project > Import Type Library**.

2. In the dialog that opens choose ABBYY FlexiCapture 12 SDK Type Library in the list. Make sure that Generate Component Wrapper flag is turned on. Click **Install**.

   > [!NOTE]
   >
   > An error at this stage may indicate that the system environment variable Path does not contain the necessary paths. Modify it to include the path to the mscoree.tlb file (generally it is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

3. New components appear on the ActiveX tab of the Components palette — **InprocLoader** and **OutprocLoader**. You can add one of these components directly onto your form and use it to load the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object.

For example, you add the **InprocLoader** component onto your form. The following code will be added automatically:

```pascal theme={null}
uses FCEngine_TLB;
type
  TForm1 = class(TForm)
    InprocLoader1: TInprocLoader;
    ...
    private
      { Private declarations }
    public
      { Public declarations }
    end;
```

In your implementation use the **Load** method of the [**InprocLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/inprocloader.md) object to load **Engine**:

```pascal theme={null}
engineLoader.Set_CustomerProjectId(GetCustomerProjectId);
engineLoader.Set_LicensePath(GetLicensePath);
engineLoader.Set_LicensePassword(GetLicensePassword);
engine := engineLoader.GetEngine();
```

When you no longer need FlexiCapture SDK functionality, unload the **Engine** using the [**Unload**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader-unload.md) method of the loader object.

```pascal theme={null}
InprocLoader1.Unload;
```

## Deinitialization of the Engine Object

If not all the objects which were created and used by the application have been deleted before the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object deinitialization, the "Engine deinitialization failed" exception is thrown. If all the objects have been deleted, the exception may be caused by the scavenger operation. In Delphi all objects with the *nil* value are deleted only after the exit from the procedure in which the objects were declared. Therefore, the entire ABBYY FlexiCapture SDK code must be inserted into a separate procedure, and this procedure must be called before the **Engine** object deinitialization.

> [!NOTE]
>
> You can use the [**StartLogging**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine-startlogging.md) method of the **Engine** object to get the list of objects that have not been deleted.

## See also

[Different Ways to Load the Engine Object](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/differentwaystoloadengine.md)
