Sometimes you want to give the user the opportunity to format a diskette prior to for instance copying some files to a floppy. You can use the undocumented SHFormatDrive function as demonstrated in the example below.
function SHFormatDrive(hWnd: HWND;
Drive: Word;
fmtID: Word;
Options: Word): DWord; stdcall;
external 'Shell32.dll' name 'SHFormatDrive';
const
{Constants for the SHFormatDrive API function}
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;
type
{The function will return one of these values to indicate
failure or success}
TFormatResult = (frOK, frError, frCanceled, frNotPossible);
function FormatDrive(const Drive: Char): TFormatResult;
begin
case SHFormatDrive(Application.Handle,
(Ord(Drive) and $3F)-1,
SHFMT_ID_DEFAULT, SHFMT_OPT_QUICK) of
SHFMT_ERROR : Result:=frError;
SHFMT_CANCEL : Result:=frCanceled;
SHFMT_NOFORMAT : Result:=frNotPossible;
else
Result:=frOK;
end;
end;
Source: www.guidogybels.net.