您的位置:首页-> 资讯中心-> 网络编程-> ASP技术-> ASP学习:远程注册自己的组件(3)

ASP技术

Txlist

本类阅读TOP10

Txtop

精品推荐
ASP学习:远程注册自己的组件(3)

作者: possible_Y     来源:CSDN  加入时间:2004-8-29 宇宙软件下载

Sub getAllDlls(oParentFolder) '通过fso列举所有的dll和ocx文件

   Dim oSubFolders, oFile, oFiles

   Set oSubFolders = oParentFolder.SubFolders

   Set opFiles = oParentFolder.Files  

   For Each oFile in opFiles

   IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then

   Echo("<OPTION VALUE=" & Chr(34) & oFile.Path & Chr(34) & ">" _

   & oFile.Name & "</Option>")

   End IF

   Next  

   On Error Resume Next

   For Each oFolder In oSubFolders 'Iterate All Folders in Drive

   Set oFiles = oFolder.Files

   For Each oFile in oFiles

   IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then

   Echo("<OPTION VALUE=" & Chr(34) & oFile.Path & Chr(34) & ">" _

   & oFile.Name & "</Option>")

   End IF

   Next

   Call getAllDlls(oFolder)

   Next

   On Error GoTo 0

   End Sub  

   Sub Register(strFilePath, regMethod)

   Dim theFile, strFile, oShell, exitcode

   Set theFile = oFS.GetFile(strFilePath)

   strFile = theFile.Path  

   Set oShell = CreateObject ("WScript.Shell")  

   IF regMethod = "REG" Then 'Register

   oShell.Run "c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False

   exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False)

   EchoB("regsvr32.exe exitcode = " & exitcode)

   Else 'unRegister

   oShell.Run "c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False

   exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False)

   EchoB("regsvr32.exe exitcode = " & exitcode)

   End IF  

   Cleanup oShell

   End Sub  

   Sub BuildOptions

   EchoB("Register: <INPUT TYPE=RADIO NAME=frmMethod VALUE=REG CHECKED>")

   EchoB("unRegister: <INPUT TYPE=RADIO NAME=frmMethod VALUE=UNREG>")

   End Sub  

   Function Echo(str)

   Echo = Response.Write(str & vbCrLf)

   End Function  

   Function EchoB(str)

   EchoB = Response.Write(str & "<BR>" & vbCrLf)

   End Function  

   Sub Cleanup(obj)

   If isObject(obj) Then

   Set obj = Nothing

   End IF

   End Sub  

   Sub Class_Terminate()

   Cleanup oFS

   End Sub

   End Class

   %> 


相关文章

相关软件