3 Examples

The following examples illustrate the protocols that are used by the Print Services system to perform the following:

  • Discover and use a print queue in a domain.

  • Discover and use a print queue in a workgroup.

  • Locate a print queue in a domain and establish a connection, then submit a print job to a manual duplex printer by using the Print System Asynchronous Notification Protocol [MS-PAN] and enable bidirectional IHV-defined communication between the print client and the print server.

  • Enumerate print jobs from all users, and then cancel several print jobs.

  • Provision a print queue by using the Print System Remote Protocol [MS-RPRN], from an administrative client, and then delete the same print queue by using the Print System Asynchronous Remote Protocol [MS-PAR] from a different administrative client.

  • Send a print job to an SMB share.

In all examples in this section, the print client opens, closes, and reopens the handle to the print queue multiple times. This is because the Windows API implementation for the print spooler enables and uses different processes for the print client user interface, print client applications, and internal features of the print spooler. Each of these processes can have multiple threads. For example, an application can have one thread printing in the background and another thread computing layout in the foreground. Other queries to the print server, for example, about print jobs could occur in parallel from different threads, which cause additional exchanges that are unrelated to a specific scenario on the network.

In all examples in this section, the print client retrieves information from the print server in arbitrary order, and often retrieves the same information redundantly. Methods that could be called in arbitrary order and be called redundantly are marked with an asterisk (*) in the examples.

Because handles are not generally portable between threads, and are never portable between processes, the print client could also use different handles to the same print queue for different functions, such as listening for notifications and submitting a print job.

Show: