Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
FindNext
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* FindNext - Finds next entry in given directory matching specification.
;* (Should be called only after successfully calling the FindFirst procedure.)
;*
;* Shows:   DOS Function - 4Fh (Find Next File)
;*          Operator - OFFSET
;*
;* Params:  Finfo - Pointer to 43-byte buffer. This must be the same buffer
;*                      (or a duplicate) returned from the FindFirst procedure.
;*
;* Return:  Short integer with error code
;*          0 if successful
;*          1 if no more matches found
 
FindNext PROC USES ds,
        Finfo:PFILEINFO
 
        ; Get current DTA address, pass address of pointer to hold value
        INVOKE  GetDTA,
                ADDR OldDta
 
        ; Set DTA address, pass pointer to structure
        INVOKE  SetDTA,
                Finfo
 
        mov     ah, 4Fh                 ; AH = function number
        int     21h                     ; Find Next File
 
        pushf                           ; Preserve flags
 
        ; Restore DTA address, pass pointer
        INVOKE  SetDTA,
                OldDta
 
        sub     ax, ax                  ; Set error code
        popf                            ; Recover flags
        .IF     carry?
        inc     ax                      ; Set error code to 1
        .ENDIF
        ret
 
FindNext ENDP
                                    -♦-