views:

32

answers:

2

I can't seem to find an API call that returns the driver name for a Windows printer. Note that I'm not talking about the friendly name of the printer in the printer folder, I'm talking about the name of actual driver being used as shown on the "Advanced" tab when you look at the printer properties:

Printer properties dialog

I'm trying to detect when I'm printing to the "Generic / Text Only" driver regardless of what name the user chooses for the printer. It doesn't seem like this should be hard, but I can't find it in the DEVMODE structure or anyplace else I've thought to look for it.

Thanks for the help!

A: 

Just a suggestion: use procmon (from sysinternals) to spy on all API calls, and see what call returns this string.

Pavel Radzivilovsky
Not a bad idea, so I gave it a try. But it really didn't help. It confirmed that Windows ultimately stores the data in the registry, but I need a real documented API call and I didn't see anything like that in the procmon data (not really a surprise since procmon only tracks certains types of API calls).
Scott Bussinger
then you should read about [1] Setup API [2] WMI. It's one of these.
Pavel Radzivilovsky
+2  A: 

What you are looking for is in the pDriverName field of the PRINTER_INFO_2 structure.

You can get it with EnumPrinters, then you have to do a comparison of the PRINTER_INFO_2::pPrinterName and the friendly name of DEVMODE.

Lorenzo
Thank you - that was exactly what I needed!
Scott Bussinger
You are welcome!
Lorenzo