Export (0) Print
Expand All

CommitSpoolData function

The CommitSpoolData function notifies the print spooler that a specified amount of data has been written to a specified spool file and is ready to be rendered.


HANDLE CommitSpoolData(
  _In_  HANDLE hPrinter,
  _In_  HANDLE hSpoolFile,
  DWORD cbCommit


hPrinter [in]

A handle to the printer to which the job was submitted. This should be the same handle that was used to obtain hSpoolFile with GetSpoolFileHandle.

hSpoolFile [in]

A handle to the spool file being changed. On the first call of CommitSpoolData, this should be the same handle that was returned by GetSpoolFileHandle. Subsequent calls to CommitSpoolData should pass the handle returned by the preceding call. See Remarks.


The number of bytes committed to the print spooler.

Return value

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

If the function fails, it returns INVALID_HANDLE_VALUE.


Applications submitting a spooler print job can call GetSpoolFileHandle and then directly write data to the spool file handle by calling WriteFile. To notify the print spooler that the file contains data which is ready to be rendered, the application must call CommitSpoolData and provide the number of available bytes.

If CommitSpoolData is called multiple times, each call must use the spool file handle returned by the previous call. When no more data will be written to the spool file, CloseSpoolFileHandle should be called for the file handle returned by the last call to CommitSpoolData.

Before calling CommitSpoolData, applications must set the file pointer to the position it had before it wrote data to the file. In the process of rendering the data in the spooler file, the print spooler will move the spool file pointer cbCommit bytes from the current value of file pointer.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]


Winspool.h (include Windows.h)





See also

Print Spooler API Functions



Community Additions

© 2014 Microsoft