L_PrnRegisterJobCallback

Summary

Registers and enables the firing of the job callback function.

Syntax

#include "Ltprinter.h"

L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnRegisterJobCallback(pszPrinterName, fnJobInfoCallBack, pData)

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.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Virtual Printer C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.