'EnumPrinters() + error RPC_S_SERVER_UNAVAILABLE (1722)
I am working on a sample to get the list of printer connected to machine. For that I am using EnumPrinters() API to get the printers. Randomly it gives the error RPC_S_SERVER_UNAVAILABLE (1722). I tried to search in the net, but I could not get the solution.
Please help me to fix this issue.
Solution 1:[1]
How are you calling EnumPrinters (hint - post the code)?
For some modes of API invocation, the local system will RPC to the target servers in turn - this uses RPC, so you can get RPC errors back. You may be able to get the info you need via a less heavyweight call that uses different parameters to EnumPrinters.
From the docs:
when EnumPrinters is called with a level 2 (PRINTER_INFO_2) data structure, it performs an OpenPrinter call on each remote connection. If a remote connection is down, or the remote server no longer exists, or the remote printer no longer exists, the function must wait for RPC to time out and consequently fail the OpenPrinter call. This can take a while.
Solution 2:[2]
I had this problem recently with my Windows 10 PC. I spent a lot of time with debugging of EnumPrinters, with all different sorts of levels, but nothing worked and I always got the error RPC_S_SERVER_UNAVAILABLE (1722). It turned out that something has stopped the Spooler service and even after a reboot it was disabled. After enabling the Spooler service, everything worked. You can notice the Spooler service failure by looking at the Win10 printer settings: All printers would show "not connected", even Print to PDF.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve Townsend |
| Solution 2 | Daniel Marschall |
