1

我需要通过 win32 api 获取特定打印机的可用支持的打印机文档功能。

下图中的示例打印机显示了我所指的选项。您可以通过右键单击打印机图标和单击首选项,然后单击对话框中的高级选项卡来获取此对话框。

在图像中

谁能告诉我需要调用的api,以及其他什么?

我的目标是 Windows Windows XP+ 并使用 vb6。

4

2 回答 2

2

DeviceCapabilities 函数是只读的。您正在寻找的是DocumentProperties 函数。DeviceCapabilities 实际上已经过时了,早就应该被淘汰了,因为它假设只有一个用户和一个应用程序在使用打印机。您不想为每个打印作业设置打印机属性;您想为当前打印作业设置文档属性。DocumentProperties 函数将为您执行此操作,但请密切注意上面链接中有关如何进行更改的说明。这是一个不必要的复杂功能。

于 2012-07-06T00:14:20.187 回答
1

我认为您正在寻找的是DeviceCapabilities来自 winspool.drv 的内容。来自 Microsoft 的示例代码。现在网上的大部分文档都是针对 .Net 的,所以我输入了Dan Appleman 的 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)

开发模式结构

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
于 2012-07-05T21:04:31.573 回答