LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

用ASP进行网络打印功能

admin
2010年7月8日 1:3 本文热度 5036
[p]<%@ language=vbscript %>[br]<%[br]option explicit[/p] [p]dim strsubmit 'form中用来保存提交按钮的值[br]dim strprinterpath 'form中保存网络打印机路径的值[br]dim strusername 'form中用户名的值[br]dim strpassword 'form中密码的值[br]dim strmessage 'form打印内容的值[br]dim objfs 'vbscript中的文件系统对象[br]dim objwshnet 'wsh中的网络对象[br]dim objprinter '打印对象[/p] [p]strsubmit = request.form("submit")[br]%>[/p] [p][br][br][br][br][/p] [p]<%[br]if strsubmit = "" then[br]%>[/p] [p]注意的是:[br]由于这是演示,其中有关nt的帐号和密码都是使用了不加密的手段在asp中传递的[br]真正的运用中应该对该登录过程进行安全处理。[br]
[br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br][br]
网络打印机路径:
登录帐号:
登录口令:
请输入你想打印的文字:
[br]
[/p] [p]当以上信息被提交后,就可以按照下面的代码进行打印了。[br]<%[br]else[br]' 从form中取得响应信息。[br]strprinterpath = request.form("printerpath")[br]strusername = request.form("username")[br]strpassword = request.form("password")[br]strmessage = request.form("message")[/p] [p]we will now use the vbscript filesystemobject object and the wsh network object. the network object will[br]give us the methods we need to open a printer connection, and the filesystemobject will allow us to stream our[br]output to the printer. we create these objects in the following code example: [/p] [p]set objfs = createobject("scripting.filesystemobject")[br]set objwshnet = createobject("wscript.network")[br]' 使用wsh连接网络打印机[br]objwshnet.addprinterconnection "lpt1", strprinterpath, false, strusername, strpassword[br]' 使用文件系统对象将打印设备作为一个文件使用[br]set objprinter = objfs.createtextfile("lpt1:", true)[br]' 给打印设备送出文本[br]objprinter.write(strmessage)[br]'关闭打印设备对象并进行错误陷阱处理[br]on error resume next[br]objprinter.close[br]' 如果发生错误,关闭打印连接,并输出错误信息[br]if err then[br]response.write ("error # " & cstr(err.number) & " " & err.description)[br]err.clear [br]else[br]' 操作成功,输出确认信息[br]response.write("
")[br]response.write("")[br]response.write("")[br]response.write("")[br]response.write("")[br]response.write("")[br]response.write("")[br]response.write("")[br]response.write("
打印消息送出:" & strmessage & "
网络打印机路径:" & strprinterpath & "
登录帐号:" & strusername & "
")[br]response.write("
")[br]end if[br]' 取消打印连接[br]objwshnet.removeprinterconnection "lpt1:"[br]set objwshnet = nothing[br]set objfs = nothing[br]set objprinter = nothing[br]end if[br]%>[br][br][/p]

该文章在 2010/7/8 1:03:23 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved