This topic has not yet been rated - Rate this topic

GetSpoolFileHandle function

Applies to: desktop apps only

The GetSpoolFileHandle function retrieves a handle for the spool file associated with the job currently submitted by the application.

Syntax

HANDLE GetSpoolFileHandle(
  __in  HANDLE hPrinter
);

Parameters

hPrinter [in]

A handle to the printer to which the job was submitted. This should be the same handle that was used to submit the job. (Use the OpenPrinter or AddPrinter function to retrieve a printer handle.)

Return value

If the function succeeds, it returns a handle to the spool file.

If the function fails, it returns INVALID_HANDLE_VALUE.

Remarks

With the handle to the spool file, your application can write to the spool file with calls to WriteFile followed by CommitSpoolData.

Your application must not call ClosePrinter on hPrinter until after it has accessed the spool file for the last time. Then it should call CloseSpoolFileHandle followed by ClosePrinter. Attempts to access the spool file handle after the original hPrinter has been closed will fail even if the file handle itself has not been closed. CloseSpoolFileHandle will itself fail if ClosePrinter is called first.

This function will fail if it is called before the print job has finished spooling.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Winspool.h (include Windows.h)

Library

Winspool.lib

Unicode and ANSI names

GetSpoolFileHandleW (Unicode) and GetSpoolFileHandleA (ANSI)

See also

Printing
Print Spooler API Functions
OpenPrinter
AddPrinter
ClosePrinter
CloseSpoolFileHandle
CommitSpoolData

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
help with error about GetSpoolFileHandle function
now i am in trouble.when i use GetSpoolFileHandle Function in VS2005,an error occours--Error 2 error : 'GetSpoolFileHandle': identifier not found.But the header file --WinSpool.h has already been included in my solution.now i do not know how to do,so help me.Looking forword your reply.