Using Run Commands to Call DLL Functions

The Run commands can be used to call DLL functions instead of running another program or batch file.

The DLL must expose the following three functions with the following prototypes:

PVOID APIENTRY Init_User_DLL ( void )

BOOL  APIENTRY TargetFunction ( PVOID pEnv, LPCSTR pszParams )

void  APIENTRY Terminate_User_DLL ( PVOID pEnv )

 

 

Compiling 32-bit or 64-bit

If you are targeting a 32-bit operating system, your DLL needs to be compiled as 32-bit.

If the DLL will be placed on a 64-bit operating system, it needs to be compiled 64-bit.

Init_User_DLL

The first time the driver loads a user DLL, it looks for a function named Init_User_DLL.

The purpose of this function is to allocate a runtime environment for your DLL. The driver passes the pointer that you return from Init_User_DLL to all subsequent function calls within the same DLL.

Terminate_User_DLL

When the driver unloads the DLL at the end of a print job, it looks for a function named Terminate_User_DLL.

The purpose of this function is to free any resources allocated with Init_User_DLL.

TargetFunction

Replace TargetFunction with the name you wish to use for your DLL function. The parameter list is passed to the target function as a single, command-line-style string (in accordance with the prototype).

Unlike the other run commands, the End of Job run command executes even if a job has been canceled (thereby giving you the opportunity to free resources). The $(JobStatus) variable is set to 0 if a job has been cancelled, otherwise it is 1.

Example: Calling A DLL Function from End of Job

Use the following fields on the Run tab to call a function in a DLL:

Field

Argument

Command:

<Path to DLL>

Use angle brackets around the path to designate that this is a DLL.

Parameters:

Parameters

Start in:

Name of function in the DLL to call

 

The following sample shows how you can configure the End of Job run command to call a function in a DLL.

In this sample the DLL is named FTPUpload.dll and the function to upload the file is called UploadFile. The function takes the full path to the file as a single argument,

See Also:

For more details on how run commands can be used to call your own DLL functions see the  Raster Image Printer Support and Documentation page.