{"id":211,"date":"2008-12-04T09:05:12","date_gmt":"2008-12-04T01:05:12","guid":{"rendered":""},"modified":"2014-02-27T23:00:25","modified_gmt":"2014-02-27T15:00:25","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8asp%e4%b8%ad%e5%ae%9e%e7%8e%b0%e7%bd%91%e7%bb%9c%e6%89%93%e5%8d%b0%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2008\/12\/04\/211.htm","title":{"rendered":"\u5982\u4f55\u5728ASP\u4e2d\u5b9e\u73b0\u7f51\u7edc\u6253\u5370\u529f\u80fd"},"content":{"rendered":"<p>\u4f7f\u7528\u5230\u7684\u6280\u672f\uff1a <br \/>\nASP,WSH,VBScript <br \/>\n\u6587\u4ef6ASPPrint.asp\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>\n&nbsp; &lt;%@ Language=VBScript %&gt; <br \/>\n&nbsp; &lt;% <br \/>\n&nbsp; Option Explicit <\/p>\n<p>&nbsp; Dim strSubmit &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &#8216;Form\u4e2d\u7528\u6765\u4fdd\u5b58\u63d0\u4ea4\u6309\u94ae\u7684\u503c <br \/>\n&nbsp; Dim strPrinterPath &nbsp; &nbsp;&#8216;Form\u4e2d\u4fdd\u5b58<a rel=\"nofollow\" class=\"wordstyle\" href=\"http:\/\/www.newasp.cn\/\" target=\"_blank\">\u7f51\u7edc<\/a>\u6253\u5370\u673a\u8def\u5f84\u7684\u503c <br \/>\n&nbsp; Dim strUsername &nbsp; &nbsp;&nbsp; &nbsp;&#8216;Form\u4e2d\u7528\u6237\u540d\u7684\u503c <br \/>\n&nbsp; Dim strPassword &nbsp; &nbsp;&nbsp; &nbsp;&#8216;Form\u4e2d\u5bc6\u7801\u7684\u503c <br \/>\n&nbsp; Dim strMessage &nbsp; &nbsp;&nbsp; &nbsp; &#8216;Form\u6253\u5370\u5185\u5bb9\u7684\u503c <br \/>\n&nbsp; Dim objFS &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;VBScript\u4e2d\u7684\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61 <br \/>\n&nbsp; Dim objWSHNet &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &#8216;WSH\u4e2d\u7684<a rel=\"nofollow\" class=\"wordstyle\" href=\"http:\/\/www.newasp.cn\/\" target=\"_blank\">\u7f51\u7edc<\/a>\u5bf9\u8c61 <br \/>\n&nbsp; Dim objPrinter &nbsp; &nbsp;&nbsp; &nbsp; &#8216;\u6253\u5370\u5bf9\u8c61 <\/p>\n<p>&nbsp; strSubmit = Request.Form(&quot;Submit&quot;) <br \/>\n&nbsp; %&gt; <\/p>\n<p>&nbsp; &lt;HTML&gt; <br \/>\n&nbsp; &lt;HEAD&gt; <br \/>\n&nbsp; &lt;META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;&gt; <br \/>\n&nbsp; &lt;\/HEAD&gt; <br \/>\n&nbsp; &lt;BODY&gt; <\/p>\n<p>&nbsp; &lt;% <br \/>\n&nbsp; If strSubmit = &quot;&quot; Then <br \/>\n&nbsp; %&gt; <\/p>\n<p>&nbsp; \u6ce8\u610f\u7684\u662f\uff1a <br \/>\n&nbsp; &nbsp; &nbsp; \u7531\u4e8e\u6211\u662f\u6f14\u793a\u8d77\u89c1\uff0c\u5176\u4e2d\u6709\u5173NT\u7684\u5e10\u53f7\u548c\u5bc6\u7801\u90fd\u662f\u4f7f\u7528\u4e86\u4e0d\u52a0\u5bc6\u7684\u624b\u6bb5\u5728 <br \/>\nASP\u4e2d\u4f20\u9012\u7684 <br \/>\n&nbsp; \u771f\u6b63\u7684\u8fd0\u7528\u4e2d\u5e94\u8be5\u5bf9\u8be5\u767b\u5f55\u8fc7\u7a0b\u8fdb\u884c\u5b89\u5168\u5904\u7406\u3002 <br \/>\n&nbsp; &lt;FORM action=&quot;ASPPrint.asp&quot; method=POST id=form name=form&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&lt;TABLE WIDTH=100% ALIGN=center BORDER=0 CELLSPACING=1 CELLPADDING <br \/>\n=1&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=right NOWRAP&gt;<a rel=\"nofollow\" class=\"wordstyle\" href=\"http:\/\/www.newasp.cn\/\" target=\"_blank\">\u7f51\u7edc<\/a>\u6253\u5370\u673a\u8def\u5f84:&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=left NOWRAP&gt;&lt;INPUT type=&quot;text&quot; id=printerpath nam <br \/>\ne=printerpath &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;value=&quot;\\\\&lt; Domain &gt;\\&lt; Printer &gt;&quot;&gt;&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;\/TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=right NOWRAP&gt;\u767b\u5f55\u5e10\u53f7:&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=left NOWRAP&gt;&lt;INPUT type=&quot;text&quot; id=username name=u <br \/>\nsername &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;value=&quot;&lt;% = strUsername %&gt;&quot;&gt;&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;\/TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=right NOWRAP&gt;\u767b\u5f55\u53e3\u4ee4:&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=left NOWRAP&gt;&lt;INPUT type=&quot;password&quot; id=password &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;name=password&gt;&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;\/TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=right NOWRAP&gt;\u8bf7\u8f93\u5165\u4f60\u60f3\u6253\u5370\u7684\u6587\u5b57:&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=left NOWRAP&gt;&lt;TEXTAREA rows=2 cols=20 id=message &nbsp;<\/p>\n<p>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;name=message&gt;&lt;\/TEXTAREA&gt;&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;\/TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=right NOWRAP&gt; &lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;TD ALIGN=left NOWRAP&gt;&lt;INPUT type=&quot;submit&quot; value=&quot;Submit&quot; &nbsp;<\/p>\n<p>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;id=submit name=submit&gt;&lt;\/TD&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&lt;\/TR&gt; <br \/>\n&nbsp; &nbsp; &nbsp;&lt;\/TABLE&gt; <br \/>\n&nbsp; &lt;\/FORM&gt; <\/p>\n<p>&nbsp; \u5f53\u4ee5\u4e0a\u4fe1\u606f\u88ab\u63d0\u4ea4\u540e\uff0c\u5c31\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u7684\u4ee3\u7801\u8fdb\u884c\u6253\u5370\u4e86\u3002 <br \/>\n&nbsp; &lt;% <br \/>\n&nbsp; Else <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u4eceform\u4e2d\u53d6\u5f97\u54cd\u5e94\u4fe1\u606f\u3002 <br \/>\n&nbsp; &nbsp; &nbsp;strPrinterPath = Request.Form(&quot;printerpath&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;strUsername = Request.Form(&quot;username&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;strPassword = Request.Form(&quot;password&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;strMessage = Request.Form(&quot;message&quot;) <\/p>\n<p>&nbsp; We will now use the VBScript FileSystemObject object and the WSH Net <br \/>\nwork object. The Network object will <br \/>\n&nbsp; give us the methods we need to open a printer connection, and the Fi <br \/>\nleSystemObject will allow us to stream our <br \/>\n&nbsp; output to the printer. We create these objects in the following code <br \/>\n&nbsp;example: &nbsp;<\/p>\n<p>&nbsp; &nbsp; &nbsp;Set objFS = CreateObject(&quot;Scripting.FileSystemObject&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;Set objWSHNet = CreateObject(&quot;WScript.Network&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u4f7f\u7528WSH\u8fde\u63a5<a rel=\"nofollow\" class=\"wordstyle\" href=\"http:\/\/www.newasp.cn\/\" target=\"_blank\">\u7f51\u7edc<\/a>\u6253\u5370\u673a <br \/>\n&nbsp; &nbsp; &nbsp;objWSHNet.AddPrinterConnection &quot;LPT1&quot;, strPrinterPath, False, str <br \/>\nUsername, strPassword <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u4f7f\u7528\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61\u5c06\u6253\u5370\u8bbe\u5907\u4f5c\u4e3a\u4e00\u4e2a\u6587\u4ef6\u4f7f\u7528 <br \/>\n&nbsp; &nbsp; &nbsp;Set objPrinter = objFS.CreateTextFile(&quot;LPT1:&quot;, True) <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u7ed9\u6253\u5370\u8bbe\u5907\u9001\u51fa\u6587\u672c <br \/>\n&nbsp; &nbsp; &nbsp;objPrinter.Write(strMessage) <br \/>\n&nbsp; &nbsp; &nbsp;&#8216;\u5173\u95ed\u6253\u5370\u8bbe\u5907\u5bf9\u8c61\u5e76\u8fdb\u884c\u9519\u8bef\u9677\u9631\u5904\u7406 <br \/>\n&nbsp; &nbsp; &nbsp;On Error Resume Next <br \/>\n&nbsp; &nbsp; &nbsp;objPrinter.Close <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u5173\u95ed\u6253\u5370\u8fde\u63a5\uff0c\u5e76\u8f93\u51fa\u9519\u8bef\u4fe1\u606f <br \/>\n&nbsp; &nbsp; &nbsp;If Err Then <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write (&quot;Error # &quot; &amp; CStr(Err.Number) &amp; &quot; &quot; &amp; Err.Desc <br \/>\nription) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Err.Clear &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp;Else <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&#8216; \u64cd\u4f5c\u6210\u529f\uff0c\u8f93\u51fa\u786e\u8ba4\u4fe1\u606f <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;CENTER&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TABLE WIDTH=100% ALIGN=center BORDER=0 CELLSP <br \/>\nACING=1 CELLPADDING=1&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;&lt;B&gt;\u6253\u5370\u6d88\u606f\u9001\u51fa:&lt;\/B&gt;&lt;\/TD&gt;&quot; <br \/>\n) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TD ALIGN=LEFT&gt;&quot; &amp; strMessage &amp; &quot;&lt;\/TD&gt;&lt;\/TR&gt;&quot;) <\/p>\n<p>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;&lt;B&gt;<a rel=\"nofollow\" class=\"wordstyle\" href=\"http:\/\/www.newasp.cn\/\" target=\"_blank\">\u7f51\u7edc<\/a>\u6253\u5370\u673a\u8def\u5f84:&lt;\/B&gt;&lt;\/TD <br \/>\n&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TD ALIGN=LEFT&gt;&quot; &amp; strPrinterPath &amp; &quot;&lt;\/TD&gt;&lt;\/TR <br \/>\n&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;&lt;B&gt;\u767b\u5f55\u5e10\u53f7:&lt;\/B&gt;&lt;\/TD&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;TD ALIGN=LEFT&gt;&quot; &amp; strUsername &amp; &quot;&lt;\/TD&gt;&lt;\/TR&gt;&quot;) <\/p>\n<p>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;\/TABLE&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;Response.Write(&quot;&lt;\/CENTER&gt;&quot;) <br \/>\n&nbsp; &nbsp; &nbsp;End If <br \/>\n&nbsp; &nbsp; &nbsp;&#8216; \u53d6\u6d88\u6253\u5370\u8fde\u63a5 <br \/>\n&nbsp; &nbsp; &nbsp;objWSHNet.RemovePrinterConnection &quot;LPT1:&quot; <br \/>\n&nbsp; &nbsp; &nbsp;Set objWSHNet &nbsp;= Nothing <br \/>\n&nbsp; &nbsp; &nbsp;Set objFS &nbsp; &nbsp;&nbsp; = Nothing <br \/>\n&nbsp; &nbsp; &nbsp;Set objPrinter = Nothing <br \/>\n&nbsp; End If <br \/>\n&nbsp; %&gt; <br \/>\n&nbsp; &lt;\/BODY&gt; <br \/>\n&nbsp; &lt;\/HTML&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u5230\u7684\u6280\u672f\uff1a ASP,WSH,VBScript \u6587\u4ef6ASPPrint.asp\u4ee3\u7801\u5982\u4e0b\uff1a &nbsp; &lt;%@ Language=VBScript %&gt; &nbsp; &lt;% &nbsp; Option Explicit &#038;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":66092,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions\/66092"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=211"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}