ybbihsse 发表于 2011-1-3 18:42:49

操作打印机的问题

有没有操作打印机的示例呀

指定打印机端口USB001

检查打印机是否联机

检查打印机是否被暂停了

只要这几个简单的示例就好了!!!

ybbihsse 发表于 2011-1-4 12:28:48

有没有人会知道哦~~~

kodin 发表于 2011-1-6 13:26:25

一般会调用第三方EXE或DLL,功能较全面。

官方论坛见过有一个相关的UDF,可以自己搜搜。

ybbihsse 发表于 2011-1-6 15:13:04

回复 3# kodin


    有搜过,搜不到哦~~~

kingfirekkk 发表于 2011-1-7 08:22:25

官网有个UDF,不知道是不是楼主要找的那个?
原贴地址:(没钱的,路过的,请看下面的代码:)
http://www.autoitscript.com/forum/topic/51054-printing-using-udf-and-a-dll/page__st__180__p__852981__hl__printer__fromsearch__1#entry852981

原文描述如下:
This is a printing UDF which allows you to print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images. Useful for labels, reports, graphs and standard forms. Can also print barcodes. It uses my printmg.dll. It is not intended to do the sorts of thing you can do with the Word UDF by big_daddy.
Note the dll is 32 bit and so only works with 32 bit applications.

附件如下:

ybbihsse 发表于 2011-1-9 16:30:41

额,这也收费呀~~~啊啊。。。下载下来看下哦。

ybbihsse 发表于 2011-1-9 16:57:14

回复 5# kingfirekkk


    不行哦。这个UDF是操作打印的样式什么之类的,我要的是想可以设置 打印机一些参数的UDF哦。

lingyunzu 发表于 2011-1-9 22:49:24

很好,刚好有用。

ybbihsse 发表于 2011-1-10 13:19:44

额,不好用呀。

kingfirekkk 发表于 2011-1-14 08:22:22

以下代码供参考,可实现楼主需要的部分功能:
$intPrinters = 1

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")

For $objItem In $colItems
    if $objItem.Queued > 0 or $objItem.PrinterStatus <> 3 or $objItem.PrinterState <> 0 Then
    ConsoleWrite("Printers on " _
             & $objItem.name & ", Printer Number: " & $intPrinters & @LF & _
            "====================================" & @LF & _
            "Availability: " & $objItem.Availability & @LF & _
            "Description: " & $objItem.Description & @LF & _
            "Printer: " & $objItem.DeviceID & @LF & _
            "Driver Name: " & $objItem.DriverName & @LF & _
            "Port Name: " & $objItem.PortName & @LF & _
            "Printer State: " & $objItem.PrinterState & @LF & _
            "Printer Status: " & $objItem.PrinterStatus & @LF & _
            "PrintJobDataType: " & $objItem.PrintJobDataType & @LF & _
            "Print Processor: " & $objItem.PrintProcessor & @LF & _
            "Spool Enabled: " & $objItem.SpoolEnabled & @LF & _
            "Separator File: " & $objItem.SeparatorFile & @LF & _
            "Queued: " & $objItem.Queued & @LF & _
            "Status: " & $objItem.Status & @LF & _
            "StatusInfo: " & $objItem.StatusInfo & @LF & _
            "Published: " & $objItem.Published & @LF & _
            "Shared: " & $objItem.Shared & @LF & _
            "ShareName: " & $objItem.ShareName & @LF & _
            "Direct: " & $objItem.Direct & @LF & _
            "Location: " & $objItem.Location & @LF & _
            "Priority: " & $objItem.Priority & @LF & _
            "Work Offline: " & $objItem.WorkOffline & @LF & _
            "Horizontal Res: " & $objItem.HorizontalResolution & @LF & _
            "Vertical Res: " & $objItem.VerticalResolution )
    ConsoleWrite(@lf & "************************************************************************************" & @lf)
    EndIf
    $intPrinters = $intPrinters + 1
Next

执行结果如下:

Printer: \\IP\HP LaserJet P1007   
Driver Name: HP LaserJet P1007
Port Name: USB001   ; (端口名,可获取后进行选择)
Printer State: 16         
Printer Status: 1          ;(1为联机,其它的状态可能要自己找WMI的资料看看了。。)
PrintJobDataType: RAW
Print Processor: HP1006S
Spool Enabled: True
Separator File:
Queued: False
Status: Error
StatusInfo:
Published: False
Shared: True
ShareName: HPLaserJ
Direct: False
Location:
Priority: 1
Work Offline: False       ;(打印机是否在线)
Horizontal Res: 600
Vertical Res: 600
************************************************************************************

ybbihsse 发表于 2011-1-14 09:06:20

回复 10# kingfirekkk


    谢谢!!
页: [1]
查看完整版本: 操作打印机的问题