国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

用ASP進行網絡打印的功能_ASP教程

2024-05-04 11:04:41
字體:
來源:轉載
供稿:網友

推薦:用ASP建立站內搜索
假如你擁有一個龐大的網站,內容又多,那么來訪者往往很難找到自己所需要的東東,這時候你就需要一個站內搜索來幫助來訪者更快的找到索要的資料了!現在你就可以用asp輕易的實現這種功能,何況現在支持asp的站點這么多,利用這個搜索引擎可以搜索到你的主頁里面任何一

 <%@ 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: 

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整合一個SQL語句類
我們在寫asp數據庫程序的時候,通常都會用到SQL語句,而在增加數據和更新數據的時候,通常會使用一下方式:insert into message (incept,sender,title,content,sendtime,flag,issend) values ('incept(i)','membername','title','message',Now(),0,1) 當字段比較多的時

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泰州市| 大安市| 巴青县| 花垣县| 自贡市| 马山县| 广河县| 岱山县| 翁源县| 项城市| 武定县| 丹凤县| 建阳市| 集贤县| 涞水县| 怀来县| 汾西县| 永城市| 古蔺县| 新建县| 牙克石市| 常德市| 彝良县| 澄迈县| 马公市| 泾阳县| 浏阳市| 繁昌县| 龙海市| 东莞市| 彩票| 奉新县| 岐山县| 麻栗坡县| 遂昌县| 江油市| 斗六市| 鄱阳县| 博湖县| 太原市| 丰宁|