Platform SDK: Win32 API

Int 21h Function 440Dh Minor Code 71h (FAT32)

Retrieves the first cluster of the specified file or directory. This function is only supported by Windows 95. It will fail if called under MS-DOS. To call this function, the caller must hold a level 3 lock on the drive.

mov ax, 440Dh            ; Generic IOCTL
mov bx, CharSet          ; See below
mov ch, DeviceCat        ; See below
mov cl, 71h              ; Get first cluster
mov dx, seg PathName     ; See below  
mov ds, dx
mov dx, offset PathName  
int 21h

jc error_handler         ; Carry set means error

Parameters

CharSet
The character set of PathName. This parameter must be one of the following values.
Value Description
BCS_WANSI (0) Windows ANSI character set
BCS_OEM (1) Current OEM character set
BCS_UNICODE (2) Unicode character set

DeviceCat
Specifies a FAT16, FAT12 or FAT32 drive.
Value Description
08h FAT32, FAT16, or FAT12 drive.
48h FAT32, FAT16, or FAT12 drive. This value is supported on Windows 95 OEM Service Release 2 and later.

Note: Because this call may be implemented in the device driver, the 48h form of this call may fail on FAT16 or FAT12 media. Therefore, applications making the 48h form of this call must fall back on the 08h form if the 48h call fails.

PathName
Pointer to a null-terminated string containing the path of the file or directory to retrieve the first cluster for.

Return Values

If the function is successful, clears the carry flag and sets DX:AX to the first cluster number. Otherwise, sets the carry flag and returns either the ERROR_INVALID_FUNCTION or ERROR_ACCESS_DENIED value in AX.

Remarks

The first cluster of a file is the first cluster of the FAT cluster chain describing the data associated with the file. The first cluster of a directory is the first cluster of the FAT cluster chain associated with the directory. The first cluster is the cluster that contains the "." and ".." entries. The Get First Cluster function finds any file or directory regardless of attribute (system, hidden, or read-only). It does not find volume labels.

It is the calling application's responsibility to check to see if the returned cluster number is valid. The following code fragment checks for a valid cluster number and sets a flag accordingly. Note that the maxClus variable is a DWORD that represents the maximum legal cluster number computed from the drive parameters.

if((MAKELONG(regAX,regDX) < 2L) || (MAKELONG(regAX,regDX) > maxClus))
    bInvalidNum = TRUE;
else
    bInvalidNum = FALSE;