AddJob

  BOOL AddJob(hPrinter, Level, pData, cbBuf, pcbNeeded)    
  HANDLE hPrinter;    
  DWORD Level;    
  LPBYTE pData;    
  DWORD cbBuf;    
  LPDWORD pcbNeeded;    

The AddJob function returns a fully qualified pathname to a file that can be opened with CreateFile, and then subsequently written to with WriteFile. This allows optimum spooling performance. A JobId is also returned to allow control of the Job through the SetJob and ScheduleJob functions. When the application has completely written and closed the file with CloseHandle, the ScheduleJob function will inform the spooler that the job is complete and can be sent to the Printer.

Parameters

hPrinter

Indicates the open Printer handle that this function is to be performed upon. This Handle is obtained with the OpenPrinter function.

Level

This value must be 1.

pData

This points to an ADDJOB_INFO_1 structure.

cbBuf

This specifies the size of the buffer pointed to be pData.

pcbNeeded

This points to a variable that will be updated to contain the actual buffer size required that is pointed to by pData. If cbBuf is too small then GetLastError will indicate ERROR_BUFFER_TOO_SMALL, and pcbNeeded will contain the size required. If cbBuf is large enough, then pcbNeeded will contain the number of bytes that were copied.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.