Examples Delphi

This article demonstrates how to format a drive from a Delphi application.
procedure FormatDriveDialog;
begin
ShellExecute(Application.Handle,
'Open',
'C:\Windows\Rundll32.exe',
'Shell32.dll,SHFormatDrive',
'C:\Windows',
SW_SHOWNORMAL);
end;
function SHFormatDrive(hWnd : HWnd;
Drive, fmtID, Options : LongInt):longint;
stdcall; external 'shell32.dll';
procedure QuietFormatDrive;
const
SHFMT_ID_DEFAULT = $FFFF;
SHFMT_OPT_QUICK = $0000;
SHFMT_OPT_FULL = $0001;
SHFMT_OPT_SYSONLY = $0002;
SHFMT_ERROR = $FFFFFFFF;
SHFMT_CANCEL = $FFFFFFFE;
SHFMT_NOFORMAT = $FFFFFFFD;
begin
case SHFormatDrive(Handle, 0, SHFMT_ID_DEFAULT, SHFMT_OPT_FULL) of
SHFMT_ERROR : ShowMessage('Error on last format, drive may be
formatable');
SHFMT_CANCEL : ShowMessage('Last format was canceled');
SHFMT_NOFORMAT : ShowMessage('Drive is not formatable');
end;
end;