Intermec 6100 Reference Guide

Page of 328
SECTION 3
Supporting Windows Applications
PEN*KEY
R
 6100 Computer Programmer’s Reference Guide    3-33
This callback is called for each error and must return IDCANCEL (0x02),
IDRETRY (0x04) or 0.  If the application returns 0, the default handler proĆ
cesses the error.  For consistency, the application should handle all errors.
Use any method for displaying the message.  Make the dialog model, if posĆ
sible.  Note, based on the method of displaying the message, you may need
to translate the return values into IDCANCEL or IDRETRY for the printer
driver.
4. Perform normal printing operations.
5. Call PrtService to remove the error handler, using PRT_SETPROC
(0x0010) and a NULL value for the handler address.
6. Call PrtService to disable the driver, using PRT_DISABLE (0x0002).
Printer Services API
The IrDA printer driver includes an API to provide access to the features of the
IrDA driver that are not available through the standard Windows API.
Retrieving the API Entry Point PrtService
To use the API, the application must first obtain the entry point for the 
PrtSer-
vice
 procedure as described in the following code fragment:
hInstNorPrnt = LoadLibrary( “NORIRDA.DRV” );
if ( hInstNorPrnt <= HINSTANCE_ERROR ) {
  MessageBox( NULL, 
              “Could not open printer driver.”, 
              “ERROR”,
              MB_OK | MB_ICONEXCLAMATION );
  return FALSE;
}
lpfnPrtService = 
  (fpPrtService)GetProcAddress( hInstNorPrnt, “PrtService” );
if ( lpfnPrtService == NULL ) {
  MessageBox( NULL, 
              “Unable to get address for\nPrtService”, 
              “ERROR”, 
              MB_OK | MB_ICONEXCLAMATION );
  return FALSE;
}
Calling PrtService
NORIRDA.DRV contains an exported procedure 
PrtService(  HINSTANCE
hInst, WORD wOpt, LPARAM lParam1, LPARAM lParam2)
 that provides
the API for the driver.  The parameters to the procedure are as follows:
HINSTANCE hInst instance handle to our application.
WORD wOpt
option for action you want to perform.
LPARAM lParam1
double word that depends on the particular option.
LPARAM lParam2
double word that depends on the particular option.
The value returned by 
PrtService
 depends on the option selected.  See specific
options for more details.  The entry point can be called just like any Windows
procedure, as shown in the following fragment:
if (lpfnPrtService(hInst, PRT_ENABLE, (LPARAM)NULL,
                                  (LPARAM)NULL ) < 1) {
MessageBox( NULL, 
“Unable to enable printer driver”,
“ERROR”, 
MB_OK | MB_ICONEXCLAMATION );
return FALSE;
}
3. Windows
Applications