Registers and enables the firing of the job callback function.
#include "Ltprinter.h"
L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnRegisterJobCallback(pszPrinterName, fnJobInfoCallBack, pData)
Character string that contains the name of the LEADTOOLS Virtual Printer Driver.
Callback function to be registered. This callback function gets the Started and ended of printed job.
Void pointer that you can use to pass one or more additional parameters that the callback function(s) needs.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Initialize the COM library by calling the CoInitialize Windows C API before using callbacks. After you are finished using the callbacks release the COM library by calling the CoUninitialize Windows C API.
Win32, x64.
/* Job Callback */
L_INT EXT_CALLBACK OnJobInfoProc(L_WCHAR * pszPrinter,
DWORD dwJobID,
DWORD dwFlags,
L_VOID * pData)
{
UNREFERENCED_PARAMETER(pData);
L_WCHAR szResult[ 250 ];
wsprintfW( szResult, L"Job ID: %d.\nOn printer: ", dwJobID );
lstrcatW( szResult, pszPrinter );
switch( dwFlags )
{
case PRN_JOB_START:
MessageBoxW( NULL, szResult, L"Starting", MB_OK );
break;
case PRN_JOB_END:
MessageBoxW( NULL, szResult, L"Ending", MB_OK );
break;
default:
{
L_TCHAR szPrinter[_MAX_PATH];
memset(szPrinter, 0, sizeof(szPrinter));
#if defined(FOR_UNICODE)
wcscpy_s(szPrinter, pszPrinter);
#else
size_t num = 0;
wcstombs_s(&num, szPrinter, pszPrinter, _MAX_PATH);
#endif // #if !defined(FOR_UNICODE)
L_PrnCancelPrintedJob(szPrinter, dwJobID);
}
}
return 1;
}
L_INT RegistrationJobCallback( )
{
int nRet = L_PrnRegisterJobCallback(TEXT("TEST LEADTOOLS Printer"),OnJobInfoProc,NULL);
if (nRet == SUCCESS)
{
L_PrnUnRegisterJobCallback(TEXT("TEST LEADTOOLS Printer")) ;
}
return nRet;
}