ExtEscape function

The ExtEscape function enables an application to access device capabilities that are not available through GDI.


int ExtEscape(
  _In_  HDC    hdc,
  _In_  int    nEscape,
  _In_  int    cbInput,
  _In_  LPCSTR lpszInData,
  _In_  int    cbOutput,
  _Out_ LPSTR  lpszOutData


hdc [in]

A handle to the device context.

nEscape [in]

The escape function to be performed. It can be one of the following or it can be an application-defined escape function.


Checks whether the printer supports a JPEG image.


Checks whether the printer supports a PNG image.


Draws a white, gray-scale, or black rectangle.


Gets information on a specified feature setting for a PostScript driver.


Reports on whether or not the driver is a Postscript driver.


Allows the application to send data directly to a printer. Supported in compatibility mode and GDI-centric mode.


Allows the application to send data directly to a printer. Supported only in compatibility mode.


Sets a PostScript driver to GDI-centric or PostScript-centric mode.


Inserts a block of raw data in a PostScript job stream.


Sends data directly to a PostScript printer driver. Supported in compatibility mode and PostScript-centric mode.


Determines whether a particular escape is implemented by the device driver.


Enables applications to include private procedures and other resources at the document level-save context.


cbInput [in]

The number of bytes of data pointed to by the lpszInData parameter.

lpszInData [in]

A pointer to the input structure required for the specified escape. See also Remarks.

cbOutput [in]

The number of bytes of data pointed to by the lpszOutData parameter.

lpszOutData [out]

A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is called as a query function. If no data is to be returned in this structure, set cbOutput to 0. See also Remarks.

Return value

The return value specifies the outcome of the function. It is greater than zero if the function is successful, except for the QUERYESCSUPPORT printer escape, which checks for implementation only. The return value is zero if the escape is not implemented. A return value less than zero indicates an error.


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.

Use this function to pass a driver-defined escape value to a device.

Use the Escape function to pass one of the system-defined escape values to a device, unless the escape is one of the defined escapes in nEscape. ExtEscape might not work properly with the system-defined escapes. In particular, escapes in which lpszInData is a pointer to a structure that contains a member that is a pointer will fail.

Note, that the behavior described in this article is the expected behavior, but it is up to the driver to comply with this model.

The variables referenced by lpszInData and lpszOutData should not be the same or overlap. If the input and the output buffer size variables overlap, they may not contain the correct values after the call returns. For the best results, lpszInData and lpszOutData should refer to different variables.


For an example, see Sizing a JPEG or PNG Image.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Wingdi.h (include Windows.h)





See also

Print Spooler API Functions