> ## 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.

# Handle Object (IHandle Interface)

This object provides access to the handle of a resource in memory. It is returned by some methods which provide access to a bitmap image or a memory block. The object manages memory allocation and allows you to avoid memory leaks while working with these resources.

> [!WARNING]
>
> This interface does not support Automation. This means that it does not work if FlexiCapture SDK is loaded as an out-of-process server.

The object is used in the following situations:

* **If you plan to work with the resource outside FlexiCapture SDK**

You can get the handle of the resource via the **Handle** property and work with it. In this case, if you release the **Handle** object, the resource is released too. Or you can get the handle and detach **Handle** object from it (use the **Detach** method). In this case, you are responsible for releasing the resource.

* **If you plan to pass the resource to other methods of FlexiCapture SDK**

You can get the handle of the resource as **\_\_int64** via the **HandleAsInt64** property. Later you can pass the value of this property to a method of FlexiCapture SDK that requires it. If you release the **Handle** object, the resource is released too. You can release the resource manually by calling **CloseHandle** method.

## Properties

| **Name** | **Type** | **Description** |
| - | - | - |
| **Handle** | [**HANDLE\***](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/properties.md), read-only | Returns the handle of the resource. You can obtain the handle via this property and work with the resource. |
| **HandleAsInt64** | [**\_\_int64**](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/properties.md), read-only | Returns the handle of the resource as [**\_\_int64**](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/properties.md). You can pass the return value of this property to a method of FlexiCapture SDK as an input parameter. |

## Methods

| **Name** | **Description** |
| - | - |
| [**CloseHandle**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/handle-closehandle.md) | Releases the resource. |
| [**Detach**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/handle-detach.md) | Returns the handle and detaches the object from it. |
| [**SaveToArray**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/handle-savetoarray.md) | Saves the object contents as an array of bytes. |

## Output parameter

This object is the output parameter of the following methods:

* [**GetPicture**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image-getpicture.md) method of the [**Image**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md) object
* [**SaveToMemory**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/savetomemory.md) method of a number of objects

## Samples

> [accordion] C# code
>
> ```csharp theme={null}
> FCEngine.IEngine engine;
> FCEngine.IDocument doc;
> // We presume that the document have been opened and images have been added to it
> // Get bitmap handle of a color image plane of a document page
> FCEngine.IPage page = doc.Pages[0];
> FCEngine.IImageDocument imageDoc = page.Image;
> FCEngine.IImage image = imageDoc.ColorImage;
> FCEngine.IHandle hBitmap = image.GetPicture( null, 0 );
> // Work with the bitmap
> System.Drawing.Image preprocessedImage = System.Drawing.Image.FromHbitmap( hBitmap.Handle );
> ...
> Gdi32.DeleteObject( hBitmap );
> ```

## See also

[Working with Properties](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/properties.md)
