<%@ Language=VBScript %>
<%
Option Explicit
Dim strSubmit 'Form中用来保存提交按钮的值
Dim strPRinterPath 'Form中保存网络打印机路径的值
Dim strUsername 'Form中用户名的值
Dim strPassWord 'Form中密码的值
Dim strMessage 'Form打印内容的值
Dim objFS 'VBScript中的文件系统对象
Dim objWSHNet 'WSH中的网络对象
Dim objPrinter '打印对象
strSubmit = Request.Form("Submit")
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
If strSubmit = "" Then
%>
注意的是:
由于这是演示,其中有关NT的帐号和密码都是使用了不加密的手段在asp中传递的
真正的运用中应该对该登录过程进行安全处理。
<FORM action="ASPPrint.asp" method=POST id=form name=form>
<TABLE WIDTH=100% ALIGN=center BORDER=0 CELLSPACING=1 CELLPADDING=1>
<TR>
<TD ALIGN=right NOWRAP>网络打印机路径:</TD>
<TD ALIGN=left NOWRAP><INPUT type="text" id=printerpath name=printerpath
value="< Domain >< Printer >"></TD>
</TR>
<TR>
<TD ALIGN=right NOWRAP>登录帐号:</TD>
<TD ALIGN=left NOWRAP><INPUT type="text" id=username name=username
value="<% = strUsername %>"></TD>
</TR>
<TR>
<TD ALIGN=right NOWRAP>登录口令:</TD>
<TD ALIGN=left NOWRAP><INPUT type="password" id=password
name=password></TD>
</TR>
<TR>
<TD ALIGN=right NOWRAP>请输入你想打印的文字:</TD>
<TD ALIGN=left NOWRAP><TEXTAREA rows=2 cols=20 id=message
name=message></TEXTAREA></TD>
</TR>
<TR>
<TD ALIGN=right NOWRAP> </TD>
<TD ALIGN=left NOWRAP><INPUT type="submit" value="Submit"
id=submit name=submit></TD>
</TR>
</TABLE>
</FORM>
当以上信息被提交后,就可以按照下面的代码进行打印了。
<%
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:
新闻热点
疑难解答