L_EpnAddEPrintPrinter

#include "l_eprint.h"

L_INT EXT_FUNCTION L_EpnAddEPrintPrinter (pszPrinterName, nType);

L_CHAR L_FAR * pszPrinterName;

/* printer name */

EEPNPRINTERTYPE nType;

/* printer type */

Adds a new non-OEM ePrint printer to the system.

Parameter

Description

pszPrinterName

Character string that contains the printer name.

nType

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

 

Value

Meaning

 

EPN_PRINTER_NORMAL

[0] Normal ePrint printer.

 

EPN_PRINTER_TASK

[1] Task ePrint printer.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Support for Basic 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_EpnRemoveEPrintPrinter

Topics:

ePrint: Miscellaneous

 

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 ]; 
   
   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 AddEprintPrinter( ) 
{
   if( L_EpnIsSupportLocked ( EPN_SUPPORT_GENERAL ) ) 
   {
      L_EpnUnlockSupport ( "sample key", EPN_SUPPORT_GENERAL ); 
   }
   
   L_INT nRet = L_EpnAddEPrintPrinter( TEST_PRINTER_NAME, EPN_PRINTER_TASK ); 
   if( SUCCESS == nRet ) 
   {
      /* Set Printer Specifications */
      EPNPRINTERSPECIFICATIONS Specific; 
      ZeroMemory( & Specific, sizeof( EPNPRINTERSPECIFICATIONS ) ); 
      PreparePrinterSpecifications( & Specific ); 
      L_EpnSetPrinterSpecifications ( TEST_PRINTER_NAME, & Specific ); 
      
      /* Set Printer Save Options */
      EPNPRINTERMULTISAVEOPTIONS MultiSave; 
      ZeroMemory( & MultiSave, sizeof( EPNPRINTERMULTISAVEOPTIONS ) ); 
      PrepareSaveOptions( & MultiSave ); 
      L_EpnSetPrinterSaveOptions ( TEST_PRINTER_NAME, & MultiSave ); 

      /* Set 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 Printer Mail Message */
      EPNMAILMESSAGEINFO msg; 
      ZeroMemory( & msg, sizeof( EPNMAILMESSAGEINFO ) ); 
      PrepareMailMessage( & msg ); 
      L_EpnSetPrinterMailMessageInfo ( TEST_PRINTER_NAME, & msg ); 
      
      /* Set 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 Printer 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 ); 
   }
}