谢谢,wjc826194
我还有2个问题:
1、可以加ocx和dll等文件注册?
2、在显示窗口里只显示文件名?#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Local $mylist, $Button1
#Region ### START Koda GUI section ### Form=
GUICreate("控件注册", 333, 451, 193, 125)
$mylist = GUICtrlCreateList("", 5, 32, 321, 360)
GUICtrlSetLimit(-1, 200)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("开始", 8, 408, 317, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $FileList[1]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$FileList = _Find(@ScriptDir, "Ocx", $FileList)
For $i = 1 To $FileList[0]
GUICtrlSetData($mylist, $FileList[$i], 1)
RunWait("regsvr32.exe /s "&$FileList[$i])
Next
EndSwitch
WEnd
Func _Find($nPath, $nType, ByRef $sFileList, $nFlag = 1)
If StringRight($nPath, 1) = "" Then $nPath = StringTrimRight($nPath, 1)
If StringLeft($nType, 1) = "." Then $nType = StringTrimLeft($nType, 1)
Local $nSearch = FileFindFirstFile($nPath & "\*.*")
If $nSearch = -1 Then Return SetError(0)
If @error = 1 Then Return SetError(1, 1, "")
While 1
$nFile = FileFindNextFile($nSearch)
If @error Then ExitLoop
If StringRegExpReplace($nFile, '.+\.', '') = $nType Then
$sFileList[0] += 1
If UBound($sFileList) <= $sFileList[0] Then ReDim $sFileList[$sFileList[0] + 1]
$sFileList[$sFileList[0]] = $nPath & "" & $nFile
ElseIf FileGetAttrib($nPath & "" & $nFile) = "D" And $nFlag = 1 Then
_Find($nPath & "" & $nFile, $nType, $sFileList, $nFlag)
EndIf
WEnd
If $sFileList[0] = 0 Then SetError(2, 2, "")
Return $sFileList
EndFunc
|