DLL event handlers

Calling functions located in DLLs requires knowing their exact names and the details of their parameters.

The DLL external interface

When an event occurs in a Kofax ReadSoft Invoices module, the event management system tries to find a handler for the event. If a handler is found, the handler is executed according to the rules outlined below (in order).

  • If a VBA function name has been specified, the code associated with the handler is checked for that function name. If it is found, the function is called with any parameters that come with the event.
  • If a DLL file name and DLL function name are specified, the system loads the DLL and calls the specified function the definition specified as below.

If neither one of the above conditions are met, no external code is called.

Call Syntax and Semantics

A DLL function call assumes a "C" function with the following type signature and linkage:

extern "C" __declspec( dllexport) DWORD CALLBACK

Func( LPDISPATCH disp, DISPPARAMS *pDP );

The extern "C" keyword is only necessary when you are using C++.

The "__declspec( dllexport )" keyword is from Microsoft Visual C++ 4.x or higher, and it informs the compiler that the function declared is to be exported from the DLL. Other compilers and languages may require other keywords to accomplish this.

The "CALLBACK" keyword expands to "_stdcall", which forces the function to use the Win32 standard calling conventions.

All DLL functions defined as event handlers must follow these conventions .

Parameters

The disp parameter contains a pointer to an OLE Automation IDispatch interface that represents the Application object in a Kofax ReadSoft Invoices module. Use this pointer to access methods and properties according to the object hierarchy for the application. This parameter is always supplied.

The pDP parameter contains a pointer to any arguments accompanying event. The parameter can be NULL. Arguments are packaged according to OLE2 IDispatch specifications. See Microsoft's documentation for details.

Related topics

VBA and DLL event handlers: Overview

Example of an event DLL with a function

Where to place event handlers