API打印函数的问题?

jackjack 2002-09-13 05:40:25
用OpenPrinter可以获得一个打印机句柄
如何用API函数获得打印机的设备环境句柄->hdc???
就象Printer.hdc一样可直接获得打印机的设备环境句柄?
...全文
24 点赞 收藏 6
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mouseanAnya 2002-10-22
助人为快乐之本!
UP!
回复
jackjack 2002-10-11
没人会吗?
哪位帮忙顶一下!!!
回复
jackjack 2002-09-23
怎么用API获得网络打印机HDC?
哪位大虾,请不吝赐教?
回复
Calf 2002-09-19
抱歉,我也发现在使用网络激光打印机时,出现错误,现在还没有解决,如果老兄有办法,请一定告诉我。
回复
jackjack 2002-09-18
有的打印驱动正常!
用有的打印驱动则会报错!
执行到第二个DocumentProperties时报错???
回复
Calf 2002-09-17
Dim hPrinter As Long, hdc As Long, sPrinterName As String

Public Sub OpenPrinter(ByVal PrinterName As String)
Dim pd As PRINTER_DEFAULTS
Dim o As DEVMODE, i As DEVMODE
Dim l As Long
Dim V As Long, sDCName As String

If hPrinter <> 0 Then ClosePrinter
pd.pDatatype = vbNullString
pd.DesiredAccess = PRINTER_ACCESS_ADMINISTER
OpenPrinterAPI PrinterName, hPrinter, pd
l = DocumentProperties(0, hPrinter, PrinterName, o, i, 0)
o.dmSize = l
i.dmSize = l
l = DocumentProperties(0, hPrinter, PrinterName, o, i, DM_OUT_BUFFER)

V = GetVersion()
If V >= 0 Then
sDCName = "WINSPOOL"
Else
sDCName = "WINSPL16"
End If

sPrinterName = fnTrimString(o.dmDeviceName)
hdc = CreateDC(sDCName, sPrinterName, "", o)
End Sub

Public Sub ClosePrinter()
DeleteDC hdc
hdc = 0
ClosePrinterAPI hPrinter
hPrinter = 0
End Sub

'==============
Tip:
hdc 就是要的打印机设备句柄
回复
发动态
发帖子
API
创建于2007-09-28

1455

社区成员

VB API
申请成为版主
社区公告
暂无公告