GdiGetSpoolFileHandle function

The GdiGetSpoolFileHandle function returns a handle to a print job's EMF file.


HANDLE GdiGetSpoolFileHandle(
  LPWSTR     pwszPrinterName,
  LPDEVMODEW pDevmode,
  LPWSTR     pwszDocName



Caller-supplied pointer to a string representing the name of the target printer. See the following Remarks section.


Caller-supplied pointer to a DEVMODEW structure. See the following Remarks section.


Caller-supplied pointer to the print job's document name. See the following Remarks section.

Return value

If the operation succeeds, the function returns a spool file handle. Otherwise the function returns NULL.


The GdiGetSpoolFileHandle function is exported by gdi32.dll for use within a print processor's PrintDocumentOnPrintProcessor function.

When a print processor calls GdiGetSpoolFileHandle, it should supply arguments as illustrated in the following table.

Parameter Argument
pwszPrinterName Pointer to the printer name received by the print processor's OpenPrintProcessor function.
pDevmode Pointer to the DEVMODEW structure contained in the PRINTPROCESSOROPENDATA structure, received by the print processor's OpenPrintProcessor function.
pwszDocName Document name pointer received by the print processor's PrintDocumentOnPrintProcessor function.

A print processor must call the GdiGetSpoolFileHandle function before calling any other GDI printing functions, because the returned handle must be passed to the other functions. The function calls OpenPrinter to open a connection to the printer, and CreateDC to create a device context for drawing. The print processor can obtain the device context's handle by calling GdiGetDC.

For additional information, see Using GDI Functions in Print Processors.


Target Platform Universal
Header winppi.h (include Winppi.h)
Library Gdi32.Lib
DLL Gdi32.dll

See also