User defined xHarbour functions and additional DLLs

User defined xHarbour functions and additional DLLs

If your Delphi application require functions written in Clipper/Harbour for index expressions, filters or any other reasons it is possible to add and call them.

The easiest method is to modify hbudf.prg file and use vcdll.bat to produce medhbudf.dll. This file is automatically loaded on library initialization and your functions are ready for use. To directly call functions defined in DLL use Hb_LibDo function. If your application requires external DLL functions it is a good idea to check at the beginning if medhbudf.dll has been properly loaded. The following code illustrates how to do that.

var

hbc: THbConnection;

begin

hb := THbConnection.Create;

// Check if UDF dll has been properly loaded

if not hb.CheckUdfDll then

begin

writeln('medhbudf.dll not loaded!');

Exit;

end;

// call your proprietary initialization if required

hb.Hb_LibDo('myudfinit',0);

end;

If you need to load other DLLs containing xHarbour code use THbConnection.LibLoad() and THbConnection.LibFree() functions for this purpose.