Redirecting to a Printer Redirection List

To redirect the print command to one or more other printers, a device context must be created for the type of redirection desired. The CreateRedirectionDC method 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 methods 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 pPrintersList parameter.

Before using the created DC, the user should call the StartDoc and StartPage methods. After using the created DC the user should call the EndPage and EndDoc methods.

To add a printer to the printer redirection list, call AddPrinter. This method takes a pointer to an IEpnBatchPrinterInfo object that contains information about the printer to be added to the printer redirection list. Once the printer redirection list has been created, the CreateRedirectionDC method can be called to create the printer redirection device context.

Once a printer redirection list has been created, there are several methods that can be used to manipulate this printer redirection list. GetPrinterIndex 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 method returns the index of the printer within the printer redirection list. Individual printers can be removed from the printer redirection list using RemovePrinter. To get information about a printer in the printers list, call the Printer property. To get the number of printers in the printers list, call the PrintersCount property.

When the created DC is no longer needed, it should be deleted by calling DeleteDC. For every DC created using CreateRedirectionDC there must be a call to DeleteDC to free it.

For OEM Printers:

If the OEM printer is locked, then the user can use it indirectly by using the CreateRedirectionDC method.

To use the locked OEM printer indirectly, pass a valid data to the pExtraOptions parameter. The pExtraOptions parameter is a pointer to an IEpnExtraDcOptions object. Please note that the Password property of the IEpnExtraDcOptions object must be filled by the administration password that was used when the OEM printer was installed by calling the InstallOEMPrinter method.

If the printer is locked and either NULL or an invalid password is supplied in pExtraOptions, the CreateRedirectionDC method will fail and return NULL.

For more information, refer to Locking and Unlocking the OEM ePrint Printer.