找回密码
 加入
搜索
查看: 2675|回复: 5

[系统综合] 求助:注册当前目录下的ocx文件

  [复制链接]
发表于 2011-5-18 17:29:14 | 显示全部楼层 |阅读模式
大家好,请帮忙看看
用批处理命令能用AU3完成吗?
For %%a in (*.ocx) do regsvr32.exe /s %%a
发表于 2011-5-18 18:56:29 | 显示全部楼层
去看_RunDOS
发表于 2011-5-20 18:16:11 | 显示全部楼层
Dim $FileList[1]
$FileList = _Find(@ScriptDir, "Ocx", $FileList)
For $i = 1 To $FileList[0]
        ;MsgBox(0, "", $FileList[$i])
        RunWait("regsvr32.exe /s "&$FileList[$i])
Next
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
发表于 2011-5-20 18:32:21 | 显示全部楼层
绝对能,麻烦楼主看帮助。或者faq
 楼主| 发表于 2011-5-22 00:25:44 | 显示全部楼层
谢谢,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
发表于 2011-5-22 04:17:29 | 显示全部楼层
按F1在里面找
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 05:35 , Processed in 0.081517 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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