#include "LtprinterClient.h"
L_LTPRINTERCLIENT_API L_BOOL EXT_FUNCTION L_PrnClntStartup(pszPrinterName, pbtInitialData, dwLenght, ppUserData)
Callback function to be fired by the printer driver as a job is being initialized.
Character string that contains the printer's name.
Pointer to a byte array that holds the initialization data set in the server machine.
Size of the initialization data in the pbtInitialData.
Void pointer that you can set to pass one or more additional parameters that the callback function(s) needs.
Value | Meaning |
---|---|
TRUE | The job will be continued. |
FALSE | The job will be cancelled. |
The L_PrnClntStartup callback function will be fired from the printer driver, which will call this function with the pbtInitialData that contains a byte array that holds the initialization data specified for this printer.
If the user sets the value of ppUserData, the value of ppUserData will be received in the other callback functions.
The user must implement this function in the user demo DLL.
This function should be exported in the DLL module definition (def) file.
Required DLLs and Libraries
Win32, x64.
This should be included in the client demo DLL
Don't forget to include These functions in the Module Definition file (def) for this dll
These functions does not have ASCII versions
L_BOOL EXT_FUNCTION L_PrnClntStartup(const L_WCHAR *pszPrinterName, L_UCHAR * pbtInitialData,
L_ULONG dwLenght, L_VOID ** ppUserData)
{
UNREFERENCED_PARAMETER(dwLenght);
UNREFERENCED_PARAMETER(pbtInitialData);
//Function will get called as printer job starts
WCHAR szMessage[1024];
//set any user defined data to ppUserData
TCHAR * szAdditionalMessage = TEXT("additional user data");
*ppUserData = malloc(_tcslen(szAdditionalMessage) * sizeof(TCHAR));
memset(*ppUserData,0, _tcslen(szAdditionalMessage) * sizeof(TCHAR));
memcpy(*ppUserData, szAdditionalMessage, _tcslen(szAdditionalMessage) * sizeof(TCHAR));
wsprintfW(szMessage, L"Job received from printer %s", pszPrinterName);
MessageBoxW(NULL, szMessage, L"Printer Client Demo", 0);
return TRUE;
}
L_VOID EXT_FUNCTION L_PrnClntShutdown(const L_WCHAR *pszPrinterName, L_VOID * pUserData)
{
//Function will get called when job finishes
WCHAR szMessage[1024];
wsprintfW(szMessage, L"Job ended from printer %s", pszPrinterName);
MessageBoxW(NULL, szMessage, L"Printer Client Demo", 0);
//free the allocated user data
free(pUserData);
}
L_BOOL EXT_FUNCTION L_PrnClntPrintJob(PRNJOBDATA* pPrintJobData, L_VOID * pUserData)
{
//Function will get called when job is being printer
WCHAR szMessage[1024];
wsprintfW(szMessage, L"Job name %s", pPrintJobData->szPrintJobName);
MessageBoxW(NULL, szMessage, L"Printer Client Demo", 0);
//cast the user data to the appropriate format
TCHAR * szAdditionalMessage = (TCHAR*)pUserData;
MessageBox(NULL, szAdditionalMessage, TEXT("User additional data"), 0);
char *pszMessage = "Network Printer";
pPrintJobData->hUserData = GlobalAlloc(GHND, strlen(pszMessage));
PVOID pVoid = GlobalLock(pPrintJobData->hUserData);
memcpy(pVoid, pszMessage, strlen(pszMessage));
GlobalUnlock(pPrintJobData->hUserData);
pPrintJobData->uUserDataSize = (L_LONG)strlen(pszMessage);
return TRUE;
}