SECTION 3
Supporting Windows Applications
3-32 PEN*KEY
R
6200/6300 Hand-Held Computer Programmer’s Reference Guide
3. Call PrtService to register the new handler using PRT_SETPROC (0x0010)
and the address of the new handler. The new handler should have the
following prototype:
extern “C” WORD _export FAR PASCAL ShowPrtError(WORD wCurErr)
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 the erĆ
rors. You can use any method for displaying the message you want. It is
best to make your dialog model if possible. Remember that, depending on
the method of displaying the message, you may need to translate the return
values into
IDCANCEL
or
IDRETRY
so the printer driver knows how to deal
with it. For the various error conditions that can occur, see the
Error Codes
and Messages
topic, on page 3Ć35.
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)
.
See the following
Printer Services API
topic for more information about available
printer services.
Printer Services API
The NPCP printer driver includes an Applications Program Interface (API) to
provide access to the features of the NPCP 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
PrtService procedure as described in the following code fragment:
hInstNorPrnt = LoadLibrary( “NORNPCP.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;
}
3. Windows
Applications