Platform SDK: Win32 API

Int 21h Function 7304h Set_DPBForFormat (FAT32)

Implements a sub-function to perform DPB operations.

There are five sub-functions that can be implemented. The buffer at ES:DI must contain a SDPDFormatStruc structure. The value in the DWORD member, SetDPB_Function, determines which sub-function is called.

mov  dx, seg Buffer
mov  es, dx
mov  di, offset Buffer   ;See below

mov  es:[di].SDPDFormatStruc.SetDPB_Level, ExpectLevel   ;See below

mov  ax, word ptr Value1 ; initialize SDPDFormatStruc values.
                         ; See specific sub-function for details.

mov  word ptr es:[di].SDPDFormatStruc.SetDPB_Value1, ax
mov  ax, word ptr Value1 + 2
mov  word ptr es:[di].SDPDFormatStruc.SetDPB_Value1+2, ax

mov  ax, word ptr SubFunction
mov  word ptr es:[di].SDPDFormatStruc.SetDPB_Function, ax
mov  word ptr es:[di].SDPDFormatStruc.SetDPB_Function+2, 0

mov  dl, DriveNum       ;See below
mov  cx, BufferSize     ;See below
mov  ax, 7304h          ;Set_DPBForFormat
int 21h

Parameters

Buffer
The address of a buffer containing a SDPDFormatStruc structure at ES:DI.
ExpectLevel
The expected return level value. This should be 0.
DriveNum
The 1-based drive number (0=default; 1=A, 2=B, and so on).
BufferSize
The size of the buffer, in bytes.

Remarks

The value in the SetDPB_Function member of the SDPDFormatStruc structure determines which sub-function is implemented.

Value Description
0 SetDPB_SetAllocInfo
1 SetDPB_SetDPBFrmBPB
2 SetDPB_ForceMediaChng
3 SetDPB_GetSetActFATandMirr
4 SetDPB_GetSetRootDirClus

It is important to be aware of the state of the file system when using this call. If sectors of the drive are cached, or if there are files open, the function may produce unexpected results. To avoid this, ensure that the application closes all files and calls DiskReset to flush and invalidate any caches.

The SDPDFormatStruc also contains four ULONG fields: SetDPB_Value1, SetDPB_Value2, SetDPB_Value3, and SetDPB_Value4. Set these appropriately according to the requirements for each of the sub-functions.

When calling this function with DeviceIoControl, set the dwloControlCode parameter to VWIN32_DIOC_DOS_IOCTL (defined as 6 in VWIN32.H). For more information, see Using VWIN32 to Carry Out MS-DOS Functions.