[SHFormatDrive is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]
Opens the Shell's Format dialog box.
DWORD SHFormatDrive( HWND hwnd, UINT drive, UINT fmtID, UINT options );
The handle of the parent window of the dialog box. The Format dialog box must have a parent window; therefore, this parameter cannot be NULL.
The drive to format. The value of this parameter represents a letter drive starting at 0 for the A: drive. For example, a value of 2 stands for the C: drive.
The ID of the physical format. Only the following flag is currently defined.
The default format ID.
This value must be 0 or one of the following values that alter the default format options in the dialog box. This value is regarded as a bitfield and should be treated accordingly.
0x001. If this flag is set, then the Quick Format option is selected.
This function is included in Shlobj.h only in Windows XP with SP1 and later.
Windows XP: Prior to Windows XP with SP1, this function is accessible through Shell32.lib.
0x002. Selects the Create an MS-DOS startup disk option, creating a system boot disk.
Returns the format ID of the last successful format or one of the following values. The LOWORD of this value can be passed on subsequent calls as the fmtID parameter to repeat the last format.
||An error occurred during the last format. This does not indicate that the drive is unformattable.|
||The last format was canceled.|
||The drive cannot be formatted.|
The format is controlled by the dialog box interface. That is, the user must click the OK button to actually begin the format—the format cannot be started programmatically.
This call to SHFormatDrive brings up the Shell's Format dialog box for a disk in drive A, with the default formatting options selected.
SHFormatDrive(hMainWnd, 0, SHFMT_ID_DEFAULT, 0);
|Windows version||Windows XP [desktop apps only] Windows Server 2003 [desktop apps only]|
|Header||shlobj_core.h (include Shlobj.h)|
|DLL||Shell32.dll (version 5.0 or later)|