2012-07-05 142 views
1

我需要通過win32 api獲取特定打印機的可用支持打印機文檔功能。是否有獲取高級打印機設備設置的API?

我所指的選項在下圖中爲示例打印機顯示。您可以通過右鍵單擊打印機圖標和單擊首選項並單擊對話框中的高級選項卡來獲得此對話框。

in the image

誰能告訴我需要的API我需要調用,並在其他什麼?

我針對的是Windows XP +並使用vb6。

回答

1

我認爲你正在尋找的是winspool.drv的DeviceCapabilities。來自Microsoft的代碼Sample。大部分文檔的在線現在天是對於.NET,所以我在VB6定義類型從Dan Appleman's Visual Basic Programmer's Guide to the Win32 API

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 
+0

感謝您的回答,但我可以修改這些屬性嗎? – Smith 2012-07-05 21:15:59

2

的DeviceCapabilities函數是隻讀的。你要找的是DocumentProperties function。 DeviceCapabilities實際上是相當過時的,因爲它假定只有一個用戶和一個應用程序正在使用打印機,所以應該早已過時。您不想爲每個打印作業設置打印機屬性;您要爲當前打印作業設置文檔屬性。 DocumentProperties函數將爲您做到這一點,但請密切關注上面鏈接中有關如何進行更改的說明。這是一個不必要的複雜功能。