L_EpnInstallOEMPrinter

#include "l_eprint.h"

L_INT EXT_FUNCTION L_EpnInstallOEMPrinter (pOemInfo, nType)

EPNOEMPRINTERINFO L_FAR * pOemInfo;

/* pointer to a structure */

EEPNPRINTERTYPE nType;

/* OEM printer type */

Installs an OEM printer to the system.

Parameter

Description

pOemInfo

Pointer to a structure that contains the OEM printer information to be used when installing the printer.

nType

Value that represents the OEM printer type to be installed to the system. Possible values are:

 

Value

Meaning

 

EPN_PRINTER_OEM_NORMAL

Normal OEM ePrint Printer.

 

EPN_PRINTER_OEM_TASK

Task OEM ePrint Printer.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Support for OEM functionality must be unlocked by calling the L_EpnUnlockSupport function before using this function.

Required DLLs and Libraries

LPKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to ePrint Files.

See Also

Functions:

L_EpnUnlockSupport, L_EpnLockOEMPrinter, L_EpnUnlockOEMPrinter, L_EpnCreateSaveDC, L_EpnCreateRedirectionDC, L_EpnCreateEmailDC, L_EpnUninstallOEMPrinter

Topics:

ePrint: Installing and Uninstalling OEM Printers

 

Using the OEM Version of ePrint

Types of Printers

Example

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

L_VOID PrepareSaveOptions( EPNPRINTERMULTISAVEOPTIONS * pMultiSave ) 
{
   pMultiSave->uStructSize = sizeof( EPNPRINTERMULTISAVEOPTIONS ); 
   pMultiSave->nSaveElementsCount = 1; 
   pMultiSave->bUseSave = TRUE; 
   pMultiSave->pPrinterSaveOptions = new EPNPRINTERSAVEOPTIONS[ 1 ]; 
   ZeroMemory( pMultiSave->pPrinterSaveOptions, sizeof( EPNPRINTERSAVEOPTIONS ) );
   
   pMultiSave->pPrinterSaveOptions->uStructSize = sizeof( EPNPRINTERSAVEOPTIONS ); 
   
   pMultiSave->pPrinterSaveOptions->SaveOptions.uStructSize = sizeof( EPNSAVEOPTIONS ); 
   
   lstrcpy( pMultiSave->pPrinterSaveOptions->SaveOptions.szFileName, _T( "c:\\Untitled.cmp" ) ); 
   pMultiSave->pPrinterSaveOptions->SaveOptions.nFormat = FILE_CMP; // ( CMP ) 
   
   pMultiSave->pPrinterSaveOptions->SaveOptions.DocumentType = DLG_FT_SAVE_TYPE_RASTER; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.uStructSize = sizeof ( EPNRASTEROPTIONS ); 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.nBitsPerPixel = 24; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.nQFactor = 100; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.nStampBits = 24; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.nStampWidth = 128; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.nStampHeight = 128; 
   pMultiSave->pPrinterSaveOptions->SaveOptions.RasterOptions.bMultiPageFile = FALSE; 
   
   L_EpnGetDefaultNamingOptions ( & pMultiSave->pPrinterSaveOptions->NamingOptions, 
                                 sizeof( EPNNAMINGOPTIONS ) ); 
}

L_VOID PrepareMailMessage( EPNMAILMESSAGEINFO * pMsg ) 
{
   pMsg->uStructSize = sizeof( EPNMAILMESSAGEINFO ); 
   pMsg->bUseMail = TRUE; 
   pMsg->pszTo = "someone@somedomain.com";
   pMsg->pszCc = "another@anotherdomain.com";
   pMsg->pszBcc = "someonespecial@anotherdomain.com";
   pMsg->pszSubject = "Attached Images";
   pMsg->pszBody = "Hello, attached are the images."; 
   /* Index of the save options index want to be used to save the e-mailed files. 
      It is the index of the EPNPRINTERSAVEOPTIONS in the EPNPRINTERMULTISAVEOPTIONS
      passed to the L_EpnSetPrinterSaveOptions
   */
   pMsg->uEmailSaveOptionsIndex = 0; 
}

#include <Winspool.h>

L_VOID PreparePrintersList( HEPNPRINTERSLIST hPrintersList ) 
{
   /* This will add the Default Printer to the Printers List */
   DWORD dwNeededSize = 0; 
   LPTSTR pszDefaultPrinterName = NULL; 
   GetDefaultPrinter( NULL, & dwNeededSize ); 
   if( dwNeededSize > 0 ) 
   {
      pszDefaultPrinterName = (LPTSTR) GlobalAlloc( GPTR, dwNeededSize ); 
      if( pszDefaultPrinterName ) 
      {
         if( GetDefaultPrinter(pszDefaultPrinterName, & dwNeededSize ) ) 
         {
            EPNBATCHPRINTERINFO Info; 
            ZeroMemory( & Info, sizeof( EPNBATCHPRINTERINFO ) ); 
            Info.uStructSize = sizeof( EPNBATCHPRINTERINFO ); 
            lstrcpy( Info.szPrinterName, pszDefaultPrinterName ); 
            L_EpnGetDefaultEnhancedOptions ( & Info.EnhOptions, sizeof( EPNENHOPTIONS ) ); 
            Info.dwFlags = EPN_BATCHPRINT_VALIDENHANCEDOPTIONS; 
            L_EpnAddPrinterToList ( hPrintersList, & Info ); 
         }
       GlobalFree( pszDefaultPrinterName ); 
      }
   }
}

#define TEST_PRINTER_NAME "Test Printer Name"

L_VOID PreparePrinterInfo( EPNOEMPRINTERINFO * pPrinterInfo ) 
{
   pPrinterInfo->uStructSize = sizeof( EPNOEMPRINTERINFO ); 
   pPrinterInfo->pszOEMDriverName = "Test Driver Name";
   pPrinterInfo->pszOEMPrinterName = TEST_PRINTER_NAME; 
   pPrinterInfo->pszOEMMonitorName = NULL;
   pPrinterInfo->pszOEMPortName = NULL;
   pPrinterInfo->pszOEMProductName = "OEM ePrint";
   pPrinterInfo->pszOEMSerialNumber = "xxxxx-xxxxx-xxxxx";
   pPrinterInfo->pszOEMRegistryKey = "Test Printer Inc."; 
   pPrinterInfo->pszOEMRootDir = "C:\\Program Files\\OEM";
   pPrinterInfo->pszOEMHelpFile = "C:\\Program Files\\OEM/OEM.hlp";
   pPrinterInfo->pszOEMPassword = "Test Password";
   pPrinterInfo->pszOEMUrl = "http://www.eprintdriver.com";
}

L_VOID InstallOEMPrinter( ) 
{
   if(L_EpnIsSupportLocked (EPN_SUPPORT_OEM ) ) 
   {
      L_EpnUnlockSupport ( "sample key", EPN_SUPPORT_OEM ); 
   }
   
   EPNOEMPRINTERINFO PrinterInfo; 
   ZeroMemory( & PrinterInfo, sizeof( EPNOEMPRINTERINFO ) ); 
   PreparePrinterInfo( & PrinterInfo ); 
   L_INT nRet = L_EpnInstallOEMPrinter( & PrinterInfo, EPN_PRINTER_OEM_NORMAL ); 
   if( SUCCESS == nRet ) 
   {
      /* Set OEM Printer Specifications */
      EPNPRINTERSPECIFICATIONS Specific; 
      ZeroMemory( & Specific, sizeof( EPNPRINTERSPECIFICATIONS ) ); 
      PreparePrinterSpecifications( & Specific ); 
      L_EpnSetPrinterSpecifications ( TEST_PRINTER_NAME, & Specific ); 
      
      /* Set OEM Printer Save Options */
      EPNPRINTERMULTISAVEOPTIONS MultiSave; 
      ZeroMemory( & MultiSave, sizeof( EPNPRINTERMULTISAVEOPTIONS ) ); 
      PrepareSaveOptions( & MultiSave ); 
      L_EpnSetPrinterSaveOptions ( TEST_PRINTER_NAME, & MultiSave ); 

      /* Set OEM Printer Conflict Solve */

      EPNRENAMINGOPTIONS Renaming;

      ZeroMemory( & Renaming, sizeof( EPNRENAMINGOPTIONS ) );

      Renaming.uStructSize = sizeof( EPNRENAMINGOPTIONS );

      L_EpnGetDefaultRenamingOptions ( & Renaming, sizeof( EPNRENAMINGOPTIONS ) );

      L_EpnSetPrinterConflictSolving( TEST_PRINTER_NAME,
                                                             EPN_SAVE_APPEND_FAVOR_RENAME, 
                                                             &Renaming );

     
      /* Set OEM Printer Mail Message */
      EPNMAILMESSAGEINFO msg; 
      ZeroMemory( & msg, sizeof( EPNMAILMESSAGEINFO ) ); 
      PrepareMailMessage( & msg ); 
      L_EpnSetPrinterMailMessageInfo ( TEST_PRINTER_NAME, & msg ); 
      
      /* Set OEM Printer Batch Printers List */
      HEPNPRINTERSLIST hPrintersList = NULL; 
      if( SUCCESS == L_EpnCreatePrintersList ( & hPrintersList ) ) 
      {
         PreparePrintersList( hPrintersList ); 
         L_EpnSetPrinterBatchPrintersList ( TEST_PRINTER_NAME, hPrintersList ); 
         /* Destroy Printers List after setting */
         L_EpnDestroyPrintersList ( hPrintersList ); 
      }
      /* Set OEM E-Mail Configurations */
      EPNMAILCONFIGURATIONSETTINGS MailConfig; 
      ZeroMemory( & MailConfig, sizeof( EPNMAILCONFIGURATIONSETTINGS ) ); 
      MailConfig.uStructSize = sizeof( EPNMAILCONFIGURATIONSETTINGS ); 
      MailConfig.bIsMAPI = TRUE; 
      MailConfig.bUseDefaultMAPIProfile = TRUE; 
      MailConfig.dwFlags = 0; 
      L_EpnSetPrinterEmailConfiguration ( TEST_PRINTER_NAME, & MailConfig ); 
   }
}