System Delphi

// Kullanilabilecek Sabitler
const
SHFMT_OPT_FULL = $0001;
SHFMT_ERROR = $FFFFFFFF;
SHFMT_CANCEL = $FFFFFFFE;
SHFMT_ID_DEFAULT = $FFFF;
SHFMT_OPT_QUICKFORMAT = $0000;
SHFMT_OPT_SYSONLY = $0002;
function SHFormatDrive(hWnd : HWND; Drive, fmtID, Options : Word) :
Longint; stdcall;
external 'Shell32.dll' name 'SHFormatDrive'
function FormatDrive(Drive: Char): Integer;
var DriveNo: Word;
begin
if Drive in ['a'..'z'] then Dec(Drive, $20);
DriveNo := Ord(Drive) - $41;
try
Result := ShFormatDrive(Application.Handle,DriveNo,
SHFMT_ID_DEFAULT,
SHFMT_OPT_FULL);
except
Result := -1;
end;
end;
// Kullanimi:
procedure TForm1.Button1Click(Sender: TObject);
var Result: Integer;
begin
Result := FormatDrive('A');
if Result < 0 then
ShowMessage('Formatlama islemi basarisiz')
else
ShowMessage('Formatlama islemi basarili');
end;