; 显示当前目录中所有文件的文件名
#include<array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$search = FileFindFirstFile("c:\windows\system32\*.ocx")
; 检查搜索是否成功
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
Dim $n, $i, $s
$i = 0
$n = 0
$s = 0
While 1
$file = FileFindNextFile($search)
$n = $n + 1
If @error Then
FileClose($search)
ExitLoop
EndIf
WEnd
Dim $filelist[$n]
$search = FileFindFirstFile("c:\windows\system32\*.ocx")
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
While 1
$file = FileFindNextFile($search)
$filelist[$i] = $file
$i = $i + 1
If @error Then ExitLoop
WEnd
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 523, 360, 188, 111)
$Label1 = GUICtrlCreateLabel("Label1", 48, 48, 340, 17)
$Button1 = GUICtrlCreateButton("Button1", 96, 128, 73, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileClose($search)
Exit
Case $Button1
For $s = 0 To $n - 1
If $filelist[$s] = '' Then
GUICtrlSetData($Label1, '所有组件注册完毕!')
Else
GUICtrlSetData($Label1, '正在注册:' & $filelist[$s] & '组件')
ShellExecuteWait('regsvr32.exe', '/s' & $filelist[$s], '', 'open')
Sleep(200)
EndIf
Next
FileClose($search)
EndSwitch
WEnd
用最笨的办法给你写了一个例子,!! 只写了OCX,DLL可以照例子添加.!
等待高手们贴出简洁的例子.代码写得很乱.高手别见笑,! |