无法为自定函数定义两个参数的问题请教
Func _ScanFiles($DirSource)If FileExists($DirSource) = 0 Then
MsgBox(64, "提示", "" & $DirSource & "目录不存在!请重新指定有效目录.")
Else
Local $WorkingDir, $search, $file
FileChangeDir($DirSource)
$search = FileFindFirstFile("*.*")
If $search = -1 Then
;MsgBox(64, "完成提示", "在目录【" & $DirSource & "】下未找到任何文件和子目录!")
Else
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
If StringInStr(FileGetAttrib($DirSource & "\" & $file), "D") Then
_ScanFiles($DirSource & "\" & $file)
Else
If StringRight($file, 4) = ".dll" Then
$js += 1
IniWrite($config, "文件列表", $DirSource & "\" & $file, MD5Hash($DirSource & "\" & $file, 1, True))
_GUICtrlStatusBar_SetText($StatusBar1, $js & ":" & $DirSource & "\" & $file, 1)
Sleep(10)
EndIf
EndIf
WEnd
EndIf
EndIf
EndFunc ;==>_ScanFiles
上面的是正确的。
但如果我再定义一个参数就不行了(加粗部份是新加的),下面就会出错,请问是为什么?
Func _ScanFiles($DirSource,$dll)
If FileExists($DirSource) = 0 Then
MsgBox(64, "提示", "" & $DirSource & "目录不存在!请重新指定有效目录.")
Else
Local $WorkingDir, $search, $file
FileChangeDir($DirSource)
$search = FileFindFirstFile("*.*")
If $search = -1 Then
;MsgBox(64, "完成提示", "在目录【" & $DirSource & "】下未找到任何文件和子目录!")
Else
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
If StringInStr(FileGetAttrib($DirSource & "\" & $file), "D") Then
_ScanFiles($DirSource & "\" & $file)
Else
If StringRight($file, 4) = $dll Then
$js += 1
IniWrite($config, "文件列表", $DirSource & "\" & $file, MD5Hash($DirSource & "\" & $file, 1, True))
_GUICtrlStatusBar_SetText($StatusBar1, $js & ":" & $DirSource & "\" & $file, 1)
Sleep(10)
EndIf
EndIf
WEnd
EndIf
EndIf
EndFunc ;==>_ScanFiles
[ 本帖最后由 itljl 于 2008-12-8 20:14 编辑 ] 用这个就行
Search("D:\", "exe")
Func Search($current, $ext)
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
;~ MsgBox(0,0,$current & "\" & $file)
EndIf
EndIf
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
Search($current & "\" & $file, $ext)
EndIf
WEnd
Return
EndFunc ;==>Search
页:
[1]