1

I'm trying to enumerate printer models for a given manufacturer. Windows 'Add Printer' is somehow able to do that - i.e. when a manufacturer is selected in the left list a list of printer models is displayed on the right side.

I'm familiar with EnumPrinters and EnumPrinterDrivers API but neither of the related structures (PRINTER_INFO* and DRIVER_INFO*) contain printer models. DRIVER_INFO* does contain manufacturer's name but I'm not sure where to find printer models that a corresponding driver supports.

Any suggestions and pointers to on-line docs will be appreciated. Thanks.

bdristan
  • 1,048
  • 1
  • 12
  • 36

1 Answers1

2

EnumPrinterDrivers only enumerates installed printer drivers. The Add Printer dialog shows available drivers including the built-in drivers not yet installed.

The built-in driver files are in the Driver Store. For instance, if you click on HP in the left pane, the drivers for HP 910 and 915 are in this INF:

C:\Windows\System32\DriverStore\FileRepository\prnhp003.inf_amd64_4480210763997eb4\prnhp003.inf

To install these you could try the old Setup API or new Windows Installer API.

There doesn't seem to be a public API to enumerate the Driver Store contents, but the DISM command line tool can. It will parse all the right folders and INF files (for inbox drivers if you supply the /all switch to /get-drivers) and then you just need to parse the output. E.g.

Dism /online /get-drivers /all /format:list >drivers.txt

(I did suggest DriverStore Explorer but it turns out that's just a wrapper around the Windows PnPUtil.exe tool which can't enumerate inbox drivers.)

Nick Westgate
  • 3,088
  • 2
  • 34
  • 41
  • Thanks for the info. I can now see all the built-in drivers/printer models in INF files located in FileRepository\prn* folders. I wish there was an API that could query those files and return a list of printer models found in them. I think I could parse all INF files in all prn* folders. However I'm not sure if all and only printer drivers are located in prn* folders. Do you know if there is any official documentation on the subject (e.g. folder naming convention, etc.)? I do not need to install the drivers. I just need a list of printer models grouped by a manufacturer. – bdristan Mar 06 '17 at 18:39
  • I can't find a public API, but edited my answer to add some tools that can enumerate the Driver Store. – Nick Westgate Mar 06 '17 at 20:56