找回密码
 加入
搜索
查看: 1187|回复: 1

无法为自定函数定义两个参数的问题请教

[复制链接]
发表于 2008-11-29 19:09:49 | 显示全部楼层 |阅读模式
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 编辑 ]
发表于 2008-11-29 19:52:05 | 显示全部楼层
用这个就行
[au3]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[/au3]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-5 19:15 , Processed in 0.068322 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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