L_PrnInstallPrinter

#include "Ltprinter.h"

L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnInstallPrinter(pPrnInfo, uFlags)

PRNPRINTERINFO * pPrnInfo;

/* pointer to a structure */

L_UINT32 uFlags;

/* LEADTOOLS Virtual Printer Driver type */

Installs the LEADTOOLS Virtual Printer Driver to the system.

Parameter

Description

pPrnInfo

Pointer to a structure that contains the LEADTOOLS Virtual Printer Driver information to be used when installing the printer.

uFlags

Reserved for future use, use zero as the value of this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

To uninstall the LEADTOOLS Virtual Printer Driver from the system, call the L_PrnUninstallPrinter function.

Required DLLs and Libraries

LTPRINTER

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your LEADTOOLS Virtual Printer Driver Application.

See Also

Functions:

L_PrnLockPrinter, L_PrnUnlockPrinter, L_PrnUninstallPrinter, L_PrnIsLeadtoolsPrinter

Topics:

LEADTOOLS Virtual Printer: Installing and Uninstalling LEADTOOLS Virtual Printer Drivers

 

Working with the LEADTOOLS Virtual Printer Driver

Example

L_VOID PreparePrinterSpecifications( PRNPRINTERSPECIFICATIONS * pSpecific )
{
   pSpecific->uStructSize = sizeof( PRNPRINTERSPECIFICATIONS );
   /* Custom Papers IDs starts from "DMPAPER_USER + 200" */
   pSpecific->uPaperID = DMPAPER_USER + 200;
   strcpy_s( pSpecific->szPaperSizeName, "Custom Paper Name" );
   pSpecific->dPaperHeight = 11;
   pSpecific->dPaperWidth = 8;
   pSpecific->bDimensionsInInches = TRUE;
   pSpecific->bPortraitOrient = TRUE;
   strcpy_s( pSpecific->szMarginsPrinter, "Margins Printer Name" );
   pSpecific->nPrintQuality = 300;
   pSpecific->nYResolution = 300;
}

L_LTPRINTERTEX_API  L_VOID PrinterExample()
{
   /* Unlock Printer Driver support.
      Note that this is a sample key, which will not work in your toolkit. */
   L_UnlockSupport(L_SUPPORT_PRINT_DRIVER, L"TestKey");

   PRNPRINTERINFO PrnInfo;
   memset(&PrnInfo, 0, sizeof(PRNPRINTERINFO));
   PrnInfo.uStructSize=sizeof(PRNPRINTERINFO);
   PrnInfo.pszPrinterName= TEXT("TEST LEADTOOLS Printer");
   PrnInfo.pszDriverName= TEXT("TEST LEADTOOLS Printer DRIVER");
   PrnInfo.pszMonitorName= NULL;
   PrnInfo.pszPortName= NULL;
   PrnInfo.pszProductName = TEXT("LEADTOOLS Printer");
   PrnInfo.pszRegistryKey= TEXT("LEADTOOLS Printer Inc.");
   PrnInfo.pszRootDir= TEXT("C:\\Program Files\\LEAD Technologies");
   PrnInfo.pszHelpFile= TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS_Printer.hlp");
   PrnInfo.pszPassword= TEXT("TEST Password");
   PrnInfo.pszUrl= TEXT("http://www.LEADTOOLSPRINTERDRIVER.com");
   PrnInfo.pszPrinterExe= TEXT("C:\\Program Files\\LEAD Technologies\\AnyApplicationExe");

   L_INT nRet = L_PrnInstallPrinter(&PrnInfo, 0);

   if(nRet == SUCCESS)
   {
      MessageBox(0,TEXT("Install New Printer Completed Successfully"),TEXT("TEST LEADTOOLS Printer"),0);

      L_BOOL bLEADTOOLSPrinter=FALSE;
      nRet = L_PrnIsLeadtoolsPrinter(PrnInfo.pszPrinterName,&bLEADTOOLSPrinter);
      if(nRet == SUCCESS && bLEADTOOLSPrinter==TRUE)
      {
         /* Set LEADTOOLS Printer Specifications */
         PRNPRINTERSPECIFICATIONS Specific;
         PRNPRINTERSPECIFICATIONS outSpecific; 
         ZeroMemory( & Specific, sizeof( PRNPRINTERSPECIFICATIONS ) );
         ZeroMemory( & outSpecific, sizeof( PRNPRINTERSPECIFICATIONS ) );

         PreparePrinterSpecifications(&Specific);
         nRet = L_PrnSetPrinterSpecifications(PrnInfo.pszPrinterName, &Specific);

         if(nRet == SUCCESS)
         {
            L_PrnGetPrinterSpecifications(PrnInfo.pszPrinterName, &outSpecific);
         }

         L_BOOL bLocked = FALSE;
         nRet =L_PrnIsPrinterLocked(PrnInfo.pszPrinterName, &bLocked);

         if(nRet == SUCCESS)
         {
            if(bLocked)
            {
               L_PrnUnlockPrinter(PrnInfo.pszPrinterName,PrnInfo.pszPassword);
            }
            else
            {
               L_PrnLockPrinter(PrnInfo.pszPrinterName,PrnInfo.pszPassword);
            }
         }
      }
   }
}