Escape function

The Escape function enables an application to access the system-defined device capabilities that are not available through GDI. Escape calls made by an application are translated and sent to the driver.

Syntax

int Escape(
  HDC    hdc,
  int    iEscape,
  int    cjIn,
  LPCSTR pvIn,
  LPVOID pvOut
);

Parameters

hdc

A handle to the device context.

iEscape

The escape function to be performed. This parameter must be one of the predefined escape values listed in Remarks. Use the ExtEscape function if your application defines a private escape value.

cjIn

The number of bytes of data pointed to by the lpvInData parameter. This can be 0.

pvIn

A pointer to the input structure required for the specified escape.

pvOut

A pointer to the structure that receives output from this escape. This parameter should be NULL if no data is returned.

Return value

If the function succeeds, the return value is greater than zero, except with the QUERYESCSUPPORT printer escape, which checks for implementation only. If the escape is not implemented, the return value is zero.

If the function fails, the return value is a system error code.

Remarks

Note  This is a blocking or synchronous function and might not return immediately. How quickly this function returns depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user interface could make the application appear to be unresponsive.
 
The effect of passing 0 for cbInput will depend on the value of nEscape and on the driver that is handling the escape.

Of the original printer escapes, only the following can be used.

Escape Description
QUERYESCSUPPORT Determines whether a particular escape is implemented by the device driver.
PASSTHROUGH Allows the application to send data directly to a printer.
 

For information about printer escapes, see ExtEscape.

Use the StartPage function to prepare the printer driver to receive data.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

AbortDoc

DocumentProperties

EndDoc

EndPage

ExtEscape

GetDeviceCaps

Print Spooler API Functions

PrinterProperties

Printing

ResetDC

SetAbortProc

StartDoc

StartPage