我需要通过win32 api获取特定打印机支持的打印机文档功能。
我所指的选项会在下图中显示样本打印机。右键单击打印机图标和单击首选项,然后单击对话框中的高级选项卡,即可获得此对话框。
任何人都可以告诉我需要api我需要打电话,还有其他什么?
我的目标是Windows Windows XP +并使用vb6。
答案 0 :(得分:2)
DeviceCapabilities功能是只读的。您正在寻找的是DocumentProperties function。 DeviceCapabilities实际上相当过时,应该在很久以前就已经过时了,因为它假设只有一个用户而单个应用程序正在使用打印机。您不希望为每个打印作业设置打印机属性;您想为当前的打印作业设置文档属性。 DocumentProperties函数将为您执行此操作,但请密切注意上面链接中有关如何进行更改的说明。这是一个不必要的复杂功能。
答案 1 :(得分:1)
我认为您正在寻找的是来自winspool.drv的DeviceCapabilities
。来自Microsoft的Sample代码。现在大多数在线文档是针对.Net的,所以我从Dan Appleman's Visual Basic Programmer's Guide to the Win32 API输入了VB6定义
VB6的声明是:
Declare Function DeviceCapabilities& Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName as String, ByVal lpPort as String, ByVal iIndex as Long, ByVal lpOutput as String, ByVal lpDeviceMode as Long)
根据您的评论,您需要使用DocumentProperties
,它可用于检索或修改DevMode
结构。它可能有也可能没有你想要的东西。你最好的选择是得到上面的书,第12章有丰富的信息。另外看你的照片看起来你正在使用一些POS打印件,你应该查阅制造商文档,了解打印机可能支持的特定API。
Declare Function DocumentProperties& Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd as Long, ByVal hPrinter as Long, ByVal pDeviceName as String, ByVal pDeviceModeOutput as Long, ByVal pDeviceModelInput as Long, ByVal fMode as Long)
DevMode结构
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Type DEVMODE
dmDeviceName as String * CCHDEVICENAME
dmSpecVersion as Integer
dmDriverVersion as Integer
dmSize as Integer
dmDriverExtra as Integer
dmFields as Long
dmOrientation as Integer
dmPaperSize as Integer
dmPaperLength as Integer
dmPaperWidth as Integer
dmScale as Integer
dmCopies as Integer
dmDefaultSource as Integer
dmPrintQuality as Integer
dmColor as Integer
dmDuplex as Integer
dmYResolution as Integer
dmTTOption as Integer
dmCollate as Integer
dmFormName as String * CCHFORMNAME
dpBitsPerPixel as Integer
dmBitsPerPel as Long
dmPelWidth as Long
dmPelHeight as Long
dmDisplayFlags as Long
dmDisplayFrequency as Long
dmICMMethod as Long
dmICMIntent as Long
dmMediaType as Long
dmDitherType as Long
dmReserved1 as Long
dmReserved2 as Long
End Type