L_PrnRegisterJobCallback

#include "Ltprinter.h"

L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnRegisterJobCallback(pszPrinterName, fnJobInfoCallBack, pData)

Registers and enables the firing of the job callback function.

Parameters

L_TCHAR * pszPrinterName

Character string that contains the name of the LEADTOOLS Virtual Printer Driver.

PRNJOBINFOPROC fnJobInfoCallBack

Callback function to be registered. This callback function gets the Started and ended of printed job.

L_VOID * pData

Void pointer that you can use to pass one or more additional parameters that the callback function(s) needs.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

/* 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; 
} 
Help Version 22.0.2021.10.28
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Virtual Printer C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.