views:

137

answers:

2

I am using a third party tool that is pointing to images in memory with a windows handle.

The tool stats that you are responsible for freeing handle. So how would you free that handle in Delphi 7? The datatype for the handle is LONG

+3  A: 

Normally you'd use CloseHandle.

glob
+12  A: 

If the tool tells you that you're responsible for cleaning up, then it should have also told you what you should use. Take a closer look at the documentation.

You need to be more specific about what kind of handle you have. There's no one function that frees all kinds of handles.

Most kernel objects (mutex objects, threads, processes, files, pipes, events, etc.) use CloseHandle.

If you really have an image handle, like HBitmap or HIcon, then you free with DeleteObject.

Window handles (HWND) are released with DestroyWindow.

You might have a memory handle, as returned by GlobalAlloc; use GlobalFree for that.

It might not be a Windows handle at all. It might be a handle specific to your tool's API that requires an API-specific function to destroy it.

The bottom line is that you need to know what you have.

Rob Kennedy
The library documentation was written poorly and did not say "How" to free the memory. That is why I was asking the question. I downloaded a newer version of the software and found it included a demo app. In the demo app, it was shown using the GlobalFree method. Thanks for your response!
xkingpin