In the process of developing a Windows printer driver, we created this winprinfo tool to allow us to query the printer system from the point of view of an application: there are several APIs that permit a wide range of query. This tool exercises them all and proved to be indispensible in our development.
IMPORTANT - We don't mind providing support for the tool itself, but explaining what the output means or assisting in driver/application debugging is substantially beyond the scope of this free tool. The Microsoft MSDN documentation is pretty good at explaining what all these things mean, and we encourage you to Google for the names of the API functions in question for more information.
NOTE - this is a console-mode tool: it must be run in an MS-DOS/command window. If you try to run it from Explorer, it will flash a window and exit. This is not a GUI tool.
Quick Links
This code was built with Microsoft Visual C++, but strictly in the command-line mode, not using the IDE. In addition, the makefile requires GNU Make because we simply cannot stand Microsoft's NMAKE. You can get a GNU Make executable for Win32 here.
We built this to run strictly on NT/Win2000/XP platforms: if it works at all on Win95/98/ME, we'd be very surprised.
Once a printer has been opened, there are several Win32 API calls that can be used to query the device. These are DeviceCapabilities(), GetDeviceCaps, and EnumForms() (there may be more, but we'll add them as we discover them.
Using the DeviceCapabilities() API function, we are able to extract a number of individual parameters from the DEVMODE and report them.
The output is quite verbose, and this shows part of the results for the HP LaserJet 4200 named "Upstairs LaserJet" (run on Win2000):
The full output can be found HERE.C> winprinfo --printer="Upstairs LaserJet" winprinfo 1.0.1 - 2003-10-02 - http://www.unixwiz.net/tools/ Querying printer "Upstairs LaserJet" via port "" Printer Upstairs LaserJet is open fetched DEVMODE, 4360 bytes DEVMODE PARAMETERS Numeric parameters: DC_COLLATE 1 DC_COLORDEVICE 0 DC_COPIES 9999 DC_DRIVER 1280 DC_DUPLEX 0 DC_EMF_COMPLIANT -1 DC_EXTRA 4140 DC_FIELDS 0x781ff43 DC_MINEXTENT w= 98.4 h= 190.5 mm DC_MAXEXTENT w= 297.0 h= 431.8 mm...
When winprinfo is run without command-line arguments, it reports a short "help" listing that summarizes the options available, which are expanded.
--help | Show a brief help listing, then exit. |
--version | Show the program's version information, then exit. |
--printer=P | Query printer name "P", which must be enclosed in quotes if it contains spaces. Example: --printer="Upstairs LaserJet". Case does not seem to be significant in the printer name. |
--port=P | This allows providing the name of the "port", the channel through with the print data is sent to the device, but this is not usually required. Ports can be things like "COM3:" or "LPT1:", but the default of the empty string seems to be sufficient. |
--inches | Internally, all measurements are maintained and displayed in millimeters, but they can also be shown in inches. |
--points | As above, but also show PostScript "points" (1/72nd of an inch units). |
--noforms | Disable the EnumForms step. |
--enum | Enumerate all the printers on the local system. It's used to find out the proper printer names for use with the --printer=P parameter, and it overrides all the other parameters. |
2003-10-13 1.0.5 -- Lots of PC-Lint-suggested cleanups 2003-10-10 1.0.4 -- Added remote-server support 2003-10-10 1.0.3 -- Fixed error message when --printer option omitted Thu Oct 9 20:44:21 PDT 2003 -- version 1.0.2 -- Added the "--enum" parameter Thu Oct 2 13:22:20 PDT 2003 -- version 1.0.1 -- Initial releaseNavigate: More Tools