简体   繁体   English

如何使用Win32检测彩色打印机?

[英]How to detect color printer with Win32?

I have two black-and-white printers, two color printers, and some virtual printers (Fax, CutePDF Writer, etc). 我有两台黑白打印机,两台彩色打印机和一些虚拟打印机(Fax,CutePDF Writer等)。

According to the DC_COLORDEVICE query to DeviceCapabilities , only the Fax virtual printer is black-and-white. 根据对DeviceCapabilitiesDC_COLORDEVICE查询,只有传真虚拟打印机是黑白的。

According to PLANES and BITSPIXEL queries to GetDeviceCaps , all of the printers have one plane, and only Fax and CutePDF have 1 bit/pixel (are black-and-white). 根据PLANESBITSPIXELGetDeviceCaps查询,所有打印机都有一个平面,只有Fax和CutePDF有1位/像素(黑白)。

According to the NUMCOLORS query to GetDeviceCaps , only Fax is black-and-white. 根据NUMCOLORSGetDeviceCaps查询,只有传真是黑白的。

I'm not excited about querying the driver directly , so I haven't tried it yet. 我对直接查询驱动程序并不感到兴奋,所以我还没有尝试过。

How do I accurately detect a color printer with Win32? 如何使用Win32准确检测彩色打印机?

Bummer that DC_COLORDEVICE doesn't give the right answer. DC_COLORDEVICE没有给出正确答案, DC_COLORDEVICE The rest of your findings don't surprise me. 你的其他发现并不让我感到惊讶。

You could try creating an information context for the printer with CreateIC , and then use GetDeviceCaps to check the COLORRES property. 您可以尝试使用CreateIC为打印机创建信息上下文,然后使用GetDeviceCaps检查COLORRES属性。

(An information context is like a device context that you can query but can't actually draw to. It's useful when you want to know what a printer driver is going to do without actually creating a real device context, which may require the printer being online.) (信息上下文就像您可以查询但无法实际绘制的设备上下文。当您想要知道打印机驱动程序将要执行的操作而不实际创建真实的设备上下文时,这很有用,这可能需要打印机线上。)

Checking the number of planes is useless, since everything (to a good approximation) uses a single plane. 检查平面的数量是没用的,因为一切(很好地近似)使用单个平面。 The number of bits per pixel doesn't actually tell you if those pixels can be color or just grayscale (or just palette entries). 每个像素的位数实际上并不能告诉您这些像素是彩色还是仅灰度(或仅仅是调色板条目)。

Another idea is to look at the dmColor field in the default DEVMODE for the device. 另一个想法是查看设备的默认DEVMODE中的dmColor字段。

I had to solve the same problem many, many years ago (before DeviceCapabilities), but I don't remember how I did it. 很多年前(在DeviceCapabilities之前)我必须解决同样的问题,但我不记得我是怎么做到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM