views:

22

answers:

1

Hi,

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.

A: 

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.

Steve Townsend