Int 21H [1.0] Function 11H (17) Find first file

Searches the current directory on the designated drive for a matching filename.

Call with:

AH = 11H

DS:DX = segment:offset of file control block

Returns:

If function successful (matching filename found)

AL = 00H

and buffer at current disk transfer area (DTA) address filled in as an unopened normal FCB or extended FCB, depending on which type of FCB was input to function

If function unsuccessful (no matching filename found)

AL = FFH

Notes:

Use Int 21H Function 1AH to set the DTA to point to a buffer of adequate size before calling this function.

The wildcard character ? is allowed in the filename in all versions of MS-DOS. In versions 3.0 and later, the wildcard character * may also be used in a filename. If ? or * is used, this function returns the first matching filename.

An extended FCB must be used to search for files that have the system, hidden, read-only, directory, or volume-label attributes.

If an extended FCB is used, its attribute byte determines the type of search that will be performed. If the attribute byte contains 00H, only ordinary files are found. If the volume-label attribute bit is set, only volume labels will be returned (if any are present). If any other attribute or combination of attributes is set (such as hidden, system, or read-only), those files and all ordinary files will be matched.

[2.0+] Int 21H Function 4EH, which allows full access to the hierarchical directory structure, should be used in preference to this function.

Example:

Search for the first file with the extension .COM in the current directory.

buff db 37 dup (0) ; receives search result

myfcb db 0 ; drive = default

db '????????' ; wildcard filename

db 'COM' ; extension = COM

db 25 dup (0) ; remainder of FCB

.

.

.

; set DTA address

mov ah,1ah ; function number

mov dx,seg buff ; buffer address

mov ds,dx

mov dx,offset buff

int 21h ; transfer to MS-DOS

; search for first match

mov ah,11h ; function number

mov dx,seg myfcb ; address of FCB

mov ds,dx

mov dx,offset myfcb

int 21h ; transfer to MS-DOS

or al,al ; check status

jnz error ; jump if no match

.

.

.