Windows Api Enumprinters Example

Posted By admin On 25.12.19
Active8 years, 11 months ago
  1. Enumprinters Example
  2. Windows Api Enumprinters Example Cover

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.

How To Call WIN32 API Function EnumPrinters on a 32-bit Windows machine. How To Call WIN32 API Function EnumPrinters on Windows NT 4.0 Workstation and Windows. 000018058, Extended example calling EnumPrinters from ABL / 4GL. 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.

EnumPrinters Remarks If EnumPrinters returns a PRINTER_INFO_1 structure in which PRINTER_ENUM_CONTAINER is specified, this indicates that there is a hierarchy of printer objects. An application can enumerate the hierarchy by calling EnumPrinters again, setting Name to the value of the PRINTER_INFO_1 structure's pName member. Win32-EnumPrinters version 0.01 ===== The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. If EnumPrinters returns a PRINTER_INFO_1 structure in which PRINTER_ENUM_CONTAINER is specified, this indicates that there is a hierarchy of printer objects. An application can enumerate the hierarchy by calling EnumPrinters again, setting Name to the value of the PRINTER_INFO_1 structure's pName member.

Please help me to fix this issue.

Umesha MSUmesha MS
1,2817 gold badges27 silver badges54 bronze badges

1 Answer

How are you calling EnumPrinters (hint - post the code)?

Enumprinters Example

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:

Ilo 4 advanced license key. • One iLO license is required for each server on which the product is installed and used. For features that are specific to the version of iLO on your ProLiant server, see the HP iLO 4 User Guide.

Windows Api Enumprinters ExampleWindows Api Enumprinters Example

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 TownsendSteve Townsend
47.5k7 gold badges79 silver badges131 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Windows Api Enumprinters Example Cover

Not the answer you're looking for? Browse other questions tagged winapiprinting or ask your own question.