bdristan
bdristan

Reputation: 1070

How to programmatically get all printer models for a given manufacturer on windows?

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.

Upvotes: 1

Views: 1293

Answers (1)

Nick Westgate
Nick Westgate

Reputation: 3273

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.)

Upvotes: 2

Related Questions