Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 681|回复: 0
打印 上一主题 下一主题

利用ASP远程注册DLL的方法

[复制链接]

60

主题

448

帖子

6298

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6298
跳转到指定楼层
楼主
发表于 2003-3-10 10:27:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
利用ASP远程注册DLL的方法 -------------------------- <% Response.Buffer = True %> <% Server.ScriptTimeout = 500 Dim frmFolderPath, frmFilePath frmFolderPath = Request.Form("frmFolderPath") frmFilePath = Request.Form("frmDllPath") frmMethod = Request.Form("frmMethod") btnREG = Request.Form("btnREG") %> Regsvr32.asp
Regsvr Functions Insert Path to DLL Directory


<% IF Request.Form("btnFileList") <> "" OR btnREG <> "" Then Set RegisterFiles = New clsRegister RegisterFiles.EchoB("Select File") Call RegisterFiles.init(frmFolderPath) RegisterFiles.EchoB("
") IF Request.Form("btnREG") <> "" Then Call RegisterFiles.Register(frmFilePath, frmMethod) End IF Set RegisterFiles = Nothing End IF %>
<% Class clsRegister Private m_oFS Public Property Let oFS(objOFS) m_oFS = objOFS End Property Public Property Get oFS() Set oFS = Server.CreateObject("Scripting.FileSystemObject") End Property Sub init(strRoot) 'Root to Search (c:, d:, e:) Dim oDrive, oRootDir IF oFS.FolderExists(strRoot) Then IF Len(strRoot) < 3 Then 'Must Be a Drive Set oDrive = oFS.GetDrive(strRoot) Set oRootDir = oDrive.RootFolder Else Set oRootDir = oFS.GetFolder(strRoot) End IF Else EchoB("Folder ( " & strRoot & " ) Not Found.") Exit Sub End IF setRoot = oRootDir Echo("") BuildOptions End Sub Sub getAllDlls(oParentFolder) 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("") 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("") 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: ") EchoB("unRegister: ") End Sub Function Echo(str) Echo = Response.Write(str & vbCrLf) End Function Function EchoB(str) EchoB = Response.Write(str & "
" & 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 %>
^G^我站在桥上看风景,看风景的人在看我 明月装饰了我的影子,我装饰了别人的梦!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|鹤山人论坛

GMT+8, 2025-5-11 03:04 , Processed in 0.047858 second(s), 20 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表