Calling Callback Functions from Your DLLs

Just as you can pass callback functions to DLLs, you can also have your DLLs call callback functions. This section illustrates how you can create a DLL whose exported function takes a callback procedure as a parameter. Then, based on whether the user passes in a callback procedure, the procedure gets called. Listing 6.10 contains the source code to this DLL.

Listing 6.10. Calling a Callback Demo—Source Code for StrSrchLib.dll
library StrSrchLib; uses Wintypes, WinProcs, SysUtils, Dialogs; type { declare the callback function type } TFoundStrProc = procedure(StrPos: PChar); StdCall; function SearchStr(ASrcStr, ASearchStr: PChar; AProc: TFarProc): Integer; StdCall; { This function looks for ASearchStr ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.