微信公众号 
图码生活

每天发布有五花八门的文章,各种有趣的知识等,期待您的订阅与参与
电脑报 1992-2001 十年文章全集
电脑报 1992-2001 十年文章全集
包含从 1992 年 - 2001 年间,两万余篇期刊文章,查询最少输入两个字符
随便看看
读取中
读取中
标题检测站点是否支持组件
栏目网络与通信
作者ASP
发布2001年41期
  现在有很多支持ASP服务的个人主页空间,但是困惑大家的一点就是如何判断站点是否支持某些服务器组件。其实只需要一段代码就可以解决了,你所做的是只需要把下面这个检测文件上传到你的个人主页站点上,然后运行它就可以了,不用任何附加的组件。
   检测工具:
  CheckObj.asp代码如下:
  <% @ Language="VBScript" %>
  <% Option Explicit %>
  <%
  ' 这是随IIS4附带的一些组件(默认的)
  Dim theInstalledObjects(8)
  theInstalledObjects(0)= "MSWC.AdRotator"
  theInstalledObjects(1)= "MSWC.BrowserType"
  theInstalledObjects(2)= "MSWC.NextLink"
  theInstalledObjects(3)= "MSWC.Tools"
  theInstalledObjects(4)= "MSWC.Status"
  theInstalledObjects(5)= "MSWC.Counters"
  theInstalledObjects(6)= "IISSample.ContentRotator"
  theInstalledObjects(7)= "IISSample.PageCounter"
  theInstalledObjects(8)= "MSWC.PermissionChecker"
  Function IsObjInstalled(strClassString)
  On Error Resume Next
  IsObjInstalled = False
  Err = 0
  Dim xTestObj
  Set xTestObj = Server.CreateObject(strClassString)
  If 0 = Err Then IsObjInstalled = True
  Set xTestObj = Nothing
  Err = 0
  End Function
  %>
  <HTML>
  <HEAD>
  <TITLE>检测ISP是否支持ASP组件的工具</TITLE>
  </HEAD>
  <BODY>
  在下面的输入框中输入你要检测的组件的ProgId或ClassId.
  如果你没有输入的话,将使用默认值。
  <FORM action=<%=Request.ServerVariables("SCRIPT_NAME")%> method=post>
  <input type=text value="" name="classname" size=40>
  <INPUT type=submit value=Submit>
  <INPUT type=reset value=Reset>
  </FORM>
  <%
  Dim strClass
  strClass = Trim(Request.Form("classname"))
  If "" <> strClass then
  Response.Write strClass & "*"
  If Not IsObjInstalled(strClass)then
  Response.Write "<strong>没有安装,本主页提供站点不支持这个组件</strong>"
  Else
  Response.Write "安装了,本主页提供站点支持使用这个组件!"
  End If
  Response.Write "<P>" & vbCrLf
  Else
  %>
  <TABLE BORDER=0>
  <%
  Dim i
  For i=0 to UBound(theInstalledObjects)
  Response.Write "<TR><TD>" & theInstalledObjects(i)& "</TD><TD>"
  If Not IsObjInstalled(theInstalledObjects(i)) Then
  Response.Write "<strong>没有安装,本主页提供站点不支持这个组件</strong>"
  Else
  Response.Write "安装了,本主页提供站点支持使用这个组件!"
  End If
  Response.Write "</TD></TR>" & vbCrLf
  Next
  %>
  </TABLE>
  <%
  End If
  %>
  </BODY>
  </HTML>
  我提供这个工具是希望大家把自己的主页越办越好,能够充分利用你的个人主页站点提供的组件做出技术水平更高的ASP主页。