函数参考


_WinAPI_FindNextFile

Continues a file or directory search.

#Include <WinAPIEx.au3>
_WinAPI_FindNextFile ( $hSearch, $pData )

参数

$hSearch The search handle returned by a previous call to the _WinAPI_FindFirstFile() function.
$pData A pointer to the $tagWIN32_FIND_DATA structure that receives information about a found file or directory.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值, @extended 标志可能包含一个系统错误代码.

注意/说明

The order in which the search returns the files, such as alphabetical order, is not guaranteed. If the data
must be sorted, the application must do the ordering after obtaining all the results.

If the function fails because no more matching files can be found, the @extended flag will contain
ERROR_NO_MORE_FILES (18) system error code.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <Array.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $tData, $pData, $hSearch, $File
Global $List[101][2] = [[0]]

$tData = DllStructCreate($tagWIN32_FIND_DATA)
$pData = DllStructGetPtr($tData)

$hSearch = _WinAPI_FindFirstFile(@ScriptDir & '\*', $pData)
While Not @error
    $File = DllStructGetData($tData, 'cFileName')
    Switch $File
        Case '.', '..'

        Case Else
            If Not BitAND(DllStructGetData($tData, 'dwFileAttributes'), $FILE_ATTRIBUTE_DIRECTORY) Then
                $List[0][0] += 1
                If $List[0][0] > UBound($List) - 1 Then
                    ReDim $List[UBound($List) + 100][2]
                EndIf
                $List[$List[0][0]][0] = $File
                $List[$List[0][0]][1] = _WinAPI_MakeQWord(DllStructGetData($tData, 'nFileSizeLow'), DllStructGetData($tData, 'nFileSizeHigh'))
            EndIf
    EndSwitch
    _WinAPI_FindNextFile($hSearch, $pData)
WEnd

Switch @extended
    Case 18 ; ERROR_NO_MORE_FILES

    Case Else
        MsgBox(16, @extended, _WinAPI_GetErrorMessage(@extended))
        Exit
EndSwitch

_WinAPI_FindClose($hSearch)

_ArrayDisplay($List, '_WinAPI_Find...', $List[0][0])