Installs the LEADTOOLS Virtual Printer Driver to the system.
#include "Ltprinter.h"
L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnInstallPrinter(pPrnInfo, uFlags)
Pointer to a structure that contains the LEADTOOLS Virtual Printer Driver information to be used when installing the printer.
Reserved for future use. Use zero for this parameter.
| Value | Meaning |
|---|---|
| SUCCESS | The function was successful. |
| < 1 | An error occurred. Refer to Return Codes. |
To uninstall the LEADTOOLS Virtual Printer Driver from the system, call the L_PrnUninstallPrinter function, Be sure to set the pszPassword member of the pPrnInfo parameter if you want to be able to lock the printer.
Win32, x64.
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_INT PrinterExample(){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= TEXT("TEST LEADTOOLS Printer");PrnInfo.pszPortName= TEXT("TEST LEADTOOLS Printer");PrnInfo.pszProductName = TEXT("LEADTOOLS Printer");PrnInfo.pszRegistryKey= TEXT("Your Company, Inc.");PrnInfo.pszPassword= TEXT("TEST Password");// Replace with your urlPrnInfo.pszUrl= TEXT("https://www.leadtools.com/sdk/print/virtual-printer");// Replace with the correct paths for your LEADTOOLS installation folder:PrnInfo.pszRootDir= TEXT("C:\\LEADTOOLS\\Bin\\Common");PrnInfo.pszHelpFile= TEXT("C:\\LEADTOOLS\\Help\\LEADTOOLS_Printer.hlp");PrnInfo.pszPrinterExe= TEXT("C:\\LEADTOOLS\\Bin\\AnyApplicationExe");L_INT nRet = L_PrnInstallPrinter(&PrnInfo, 0);if(nRet != SUCCESS){return nRet;}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){return nRet;}if(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){return nRet;}L_PrnGetPrinterSpecifications(PrnInfo.pszPrinterName, &outSpecific);L_BOOL bLocked = FALSE;nRet =L_PrnIsPrinterLocked(PrnInfo.pszPrinterName, &bLocked);if(nRet != SUCCESS){return nRet;}if(bLocked){L_PrnUnlockPrinter(PrnInfo.pszPrinterName,PrnInfo.pszPassword);}else{L_PrnLockPrinter(PrnInfo.pszPrinterName,PrnInfo.pszPassword);}}return SUCCESS;}