如何解决组件远程注册(200分)

  • 主题发起人 主题发起人 asp100
  • 开始时间 开始时间
A

asp100

Unregistered / Unconfirmed
GUEST, unregistred user!
我正在做一个网站。需要上传一些图片,我用的是有组件上传。可是我无法在服务器上注册组件
所以作了一个远程注册的网页。可是运行不对。希望各位能人帮帮忙。
网页源代码如下
<% 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")
%>
<HTML>
<HEAD>
<TITLE>Regsvr32.asp</TITLE>
<STYLE TYPE="TEXT/CSS">
.Legend {FONT-FAMILY: veranda;
FONT-SIZE: 14px;
FONT-WEIGHT: bold;
COLOR: blue}
.FS {FONT-FAMILY: veranda;
FONT-SIZE: 12px;
BORDER-WIDTH: 4px;
BORDER-COLOR: green;
MARGIN-LEFT:2px;
MARGIN-RIGHT:2px}
TD {MARGIN-LEFT:6px;
MARGIN-RIGHT:6px;
PADDING-LEFT:12px;
PADDING-RIGHT:12px}
</STYLE>
</HEAD>
<BODY>
<FORM NAME="regForm" METHOD="POST">
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1 MARGINWIDTH=1>
<TR>
<TD VALIGN=TOP>
<FIELDSET ID=FS1 NAME=FS1 CLASS=FS>
<LEGEND CLASS=Legend>Regsvr Functions</LEGEND>
Insert Path to DLL Directory<BR>
<INPUT TYPE=TEXT NAME="frmFolderPath" VALUE="<%=frmFolderPath%>"><BR>
<INPUT TYPE=SUBMIT NAME=btnFileList VALUE="Build File List"><BR>
<%
IF Request.Form("btnFileList") <> "" OR btnREG <> "" then

RegisterFiles.EchoB("<B>Select File</B>")
Call RegisterFiles.init(frmFolderPath)
RegisterFiles.EchoB("<BR><INPUT TYPE=SUBMIT NAME=btnREG VALUE=" &amp;
Chr(34) &amp;"REG/UNREG" &amp;
Chr(34) &amp;
">")
IF Request.Form("btnREG") <> ""
then

Call RegisterFiles.Register(frmFilePath, frmMethod)
End IF
Set RegisterFiles = Nothing
End IF
%>
</FIELDSET>
</td>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<%
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("<B>Folder ( " &amp;
strRoot &amp;
" ) Not Found.")
End IF
setRoot = oRootDir
end Sub
Echo("<SELECT NAME=" &amp;
Chr(34) &amp;
"frmDllPath" &amp;
Chr(34) &amp;
">")
Call getAllDlls(oRootDir)
EchoB("</SELECT>")
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("<OPTION VALUE=" &amp;
Chr(34) &amp;
oFile.Path &amp;
Chr(34) &amp;
" > " &amp;
oFile.Name &amp;
"</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=" &amp;
Chr(34) &amp;
oFile.Path &amp;
Chr(34) &amp;
" > " &amp;
oFile.Name &amp;
"</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 " &amp;
strFile, 0, False
exitcode = oShell.Run("c:/WINNT/system32/regsvr32.exe /s " &amp;
strFile, 0, False)
EchoB("regsvr32.exe exitcode = " &amp;
exitcode)
else
'unRegister
oShell.Run "c:/WINNT/system32/regsvr32.exe /u/s " &amp;
strFile, 0, False
exitcode = oShell.Run("c:/WINNT/system32/regsvr32.exe /u/s " &amp;
strFile, 0, False)
EchoB("regsvr32.exe exitcode = " &amp;
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 &amp;
vbCrLf)
End Function
Function
EchoB(str)
EchoB = Response.Write(str &amp;
"<BR>" &amp;
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
%>
 
无组件上传也可以做的很好的,
但是我见过的大多数无组件上传都写的很不负责任,
上传大的东西比较慢,还会失败,CPU占用较多,而且会占用较多的内存
主要是程序的写法太有问题了
 

Similar threads

后退
顶部