SetPrinter

  BOOL SetPrinter(hPrinter, Level, pPrinter, Command)    
  HANDLE hPrinter;    
  DWORD Level;    
  LPBYTE pPrinter;    
  DWORD Command;    

The SetPrinter function sets printer information. It also gives commands to a 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 can be 0, or 2

pPrinter

This value is either NULL or a pointer to a PRINTER_INFO_1 data structure that contains settings for the specified printer.

Command

Specifies an operation to perform on the printer. It is not defined as a bit-mask; it specifies one, and only one, operation.

A value of zero is ignored. It is useful when calling this function just to set printer information via the pPrinter parameter.

The following values have meaning:

Value Meaning

PRINTER_CONTROL_PAUSE  
  Pause the printer.
PRINTER_CONTROL_RESUME  
  Resume a paused printer.
PRINTER_CONTROL_PURGE  
  Delete all the print jobs in the printer.

Comments

To modify printer settings, an application can call GetPrinter to get the current settings into a PRINTER data structure, modify the fields of that structure as necessary for the new printer settings, then call SetPrinter.

The SetPrinter command can be used to modify any settings of the printer except pServerName, cJobs, and AveragePPM.

Pausing a printer suspends scheduling of all print jobs for that printer, except for the one print job that may be currently printing. Print jobs can be submitted to a paused printer, but no jobs will be scheduled to print on that printer until it is commanded to resume. If a printer is purged, then all print jobs for that printer are deleted, except for the current printing job.

See Also

GetPrinter, AddPrinter