首页 | 培训 | 求学 | 参考 | 教师 | 教材 | 学校 | 招聘 | 租房 | 旅游ASKEDU.com  


培训指南—ASKEDU.com

返回 | 主页


用ASP进行网络打印功能2



[摘要]
<%
Else
" 从form中取得响应信息。
strPrinterPath = Request.Form("printerpath")
strUsername = Request.Form("username")
strPassword = Request.Form("password&qu...

<%
Else
" 从form中取得响应信息。
strPrinterPath = Request.Form("printerpath")
strUsername = Request.Form("username")
strPassword = Request.Form("password")
strMessage = Request.Form("message")
We will now use the VBScript FileSystemObject object and the WSH Network object. The Network object will
give us the methods we need to open a printer connection, and the FileSystemObject will allow us to stream our
output to the printer. We create these objects in the following code example:
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objWSHNet = CreateObject("WScript.Network")
" 使用WSH连接网络打印机
objWSHNet.AddPrinterConnection "LPT1", strPrinterPath, False, strUsername, strPassword
" 使用文件系统对象将打印设备作为一个文件使用
Set objPrinter = objFS.CreateTextFile("LPT1:", True)
" 给打印设备送出文本
objPrinter.Write(strMessage)
"关闭打印设备对象并进行错误陷阱处理
On Error Resume Next
objPrinter.Close
" 如果发生错误,关闭打印连接,并输出错误信息
If Err Then
Response.Write ("Error # " & CStr(Err.Number) & " " & Err.Description)
Err.Clear
Else
" 操作成功,输出确认信息
Response.Write("<CENTER>")
Response.Write("<TABLE WIDTH=100% ALIGN=center BORDER=0 CELLSPACING=1 CELLPADDING=1>")
Response.Write("<TR><TD ALIGN=RIGHT><B>打印消息送出:</B></TD>")
Response.Write("<TD ALIGN=LEFT>" & strMessage & "</TD></TR>")
Response.Write("<TR><TD ALIGN=RIGHT><B>网络打印机路径:</B></TD>")
Response.Write("<TD ALIGN=LEFT>" & strPrinterPath & "</TD></TR>")
Response.Write("<TR><TD ALIGN=RIGHT><B>登录帐号:</B></TD>")
Response.Write("<TD ALIGN=LEFT>" & strUsername & "</TD></TR>")
Response.Write("</TABLE>")
Response.Write("</CENTER>")
End If
" 取消打印连接
objWSHNet.RemovePrinterConnection "LPT1:"
Set objWSHNet = Nothing
Set objFS = Nothing
Set objPrinter = Nothing
End If
%>
</BODY>
</HTML>


其它培训参考信息:
用ASP进行网络打印功能1
对SQL数据库的一些攻击3
对SQL数据库的一些攻击2
对SQL数据库的一些攻击1
Jmail的主要参数列表
一个新的JMail(4.3版本)发送代码
利用XSLT把ADO记录集转换成XML6
利用XSLT把ADO记录集转换成XML5



信息来自互联网,敬请核实,谨慎使用



 




  中国 | Worldwide: United States United Kingdom Australia Canada India | Travel AgencyASKEDU.com