To redirect the print command to one or more other printers, a device context must be created for the type of redirection desired. The L_EpnCreateRedirectionDC function allows you to create a printer redirection device context. This device context can be used to redirect a print command to one or more printers contained in a printer redirection list. LEADTOOLS also provides functions for creating and manipulating this printer redirection list.
The created DC can be used as an ordinary printer DC. Each GDI command executed for this DC will be redirected to all printers in the printers list pointed to by hPrintersList parameter.
Before using the created DC, the user should call the StartDoc and StartPage Windows C DLL functions. After using the created DC the user should call the EndPage and EndDoc Windows C DLL functions.
First, the printer redirection list must be created using the L_EpnCreatePrintersList function. This creates an empty printer redirection list which can then be filled with one or more printers. To add a printer to the printer redirection list, call L_EpnAddPrinterToList. This function takes a pointer to an EPNBATCHPRINTERINFO structure that contains information about the printer to be added to the printer redirection list. Once the printer redirection list has been created, the L_EpnCreateRedirectionDC function can be called to create the printer redirection device context.
Once a printer redirection list has been created, there are several functions that can be used to manipulate this printer redirection list. L_EpnIsPrinterInList can be used to determine if a particular printer is present in the printer redirection list. If the printer is found in the printer redirection list, this function returns the index of the printer within the printer redirection list. Individual printers can be removed from the printer redirection list using L_EpnRemovePrinterFromList. To get information about a printer in the printers list, call the L_EpnGetPrinterFromList function. To get the number of printers in the printers list, call the L_EpnGetPrintersCount function. To delete the entire printer redirection list and invalidate the handle, call the L_EpnDestroyPrintersList function.
When the created DC is no longer needed, it should be deleted by calling L_EpnDeleteDC. For every DC created using L_EpnCreateRedirectionDC there must be a call to L_EpnDeleteDC to free it.
For OEM Printers:
If the OEM printer is locked, then the user can use it indirectly by using this function.
To use the locked OEM printer indirectly, pass a valid data to the pExtraOptions parameter. The pExtraOptions parameter is a pointer to an EPNEXTRADCOPTIONS structure. Please note that the pszPassword member of the EPNEXTRADCOPTIONS structure must be filled by the administration password that was used when the OEM printer was installed by calling the L_EpnInstallOEMPrinter function.
If the printer is locked and either NULL or an invalid password is supplied in pExtraOptions, the L_EpnCreateRedirectionDC function will fail and return NULL.
For more information, refer to Locking and Unlocking the OEM ePrint Printer.