> Er det muligt at fremkalde subj. via ASP?
Nedenstående stykke kode vil prøve på at skabe objekterne(find selv på
flere) fra et Array.
Hvis de eksisterer får du 'installed!', ellers får du 'not installed'.
Jeg har desuden lagt et eksempel op på
http://www.hangaround.dk/testobj.asp.
Mvh Karsten
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
' there are a number of objects that come with IIS4
' these are put in the array that's declared below
Dim theInstalledObjects(33)
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"
theInstalledObjects(9) = "SOFTWING.AspTear"
theInstalledObjects(10) = "Persits.Upload.1"
theInstalledObjects(11) = "SMTPsvg.Mailer"
theInstalledObjects(12) = "POP3svg.Mailer"
theInstalledObjects(13) = "AspNNTP.Conn"
theInstalledObjects(14) = "AspHTTP.Conn"
theInstalledObjects(15) = "AspDNS.Lookup"
theInstalledObjects(16) = "AspImage.Image"
theInstalledObjects(17) = "JMail.Message"
theInstalledObjects(18) = "Socket.TCP"
theInstalledObjects(19) = "ImgSize.Check"
theInstalledObjects(20) = "AspPing.Conn"
theInstalledObjects(21) = "LastMod.FileObj"
theInstalledObjects(22) = "WaitFor.Comp"
theInstalledObjects(23) = "AspCrypt.Crypt"
theInstalledObjects(24) = "GuidMakr.GUID"
theInstalledObjects(25) = "ASPExec.Execute"
theInstalledObjects(26) = "AspInet.FTP"
theInstalledObjects(27) = "ASPsvg.Process"
theInstalledObjects(28) = "Bible.Lookup"
theInstalledObjects(29) = "AspMX.Lookup"
theInstalledObjects(30) = "AspFile.FileObj"
theInstalledObjects(31) = "AspConv.Expert"
theInstalledObjects(32) = "AspSock.Conn"
theInstalledObjects(33) = "AspQMail.Mailer"
Function IsObjInstalled(strClassString)
On Error Resume Next
' initialize default values
IsObjInstalled = False
Err = 0
' testing code
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
' cleanup
Set xTestObj = Nothing
Err = 0
End Function
%>
<HTML>
<HEAD>
<META name="robots" content="noindex, nofollow">
<TITLE>Test of installed objects</TITLE>
</HEAD>
<BODY>
Enter the ProgId or ClassId of the component you want to test in the textbox
below. If you leave it empty, the default
components will be tested.
<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 & " is "
If Not IsObjInstalled(strClass) then
Response.Write "<strong>not installed</strong>"
Else
Response.Write "installed!"
End If
Response.Write "<P>" & vbCrLf
Else
' default: list all components that should be installed
%>
<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>not installed</strong>"
Else
Response.Write "installed!"
End If
Response.Write "</TD></TR>" & vbCrLf
Next
%>
</TABLE>
<%
End If
%>
</BODY>
</HTML>