关于格式化磁盘
There is an API hidden away in Shell32.dll called SHFormatDrive, this brings up the standard format removable drive dialog. I stumbled across this in the borland.public.delphi.winapi newsgroup.
{implementation section}
..
..
const
SHFMT_ID_DEFAULT = $FFFF;
// Formating options
SHFMT_OPT_QUICKFORMAT = $0000;
SHFMT_OPT_FULL = $0001;
SHFMT_OPT_SYSONLY = $0002;
// Error codes
SHFMT_ERROR = $FFFFFFFF;
SHFMT_CANCEL = $FFFFFFFE;
SHFMT_NOFORMAT = $FFFFFFFD;
function SHFormatDrive(Handle: HWND; Drive, ID, Options: Word): LongInt;
stdcall; external 'shell32.dll' name 'SHFormatDrive'
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
DriveComboBox1: TDriveComboBox;
procedure Button1Click(Sender: TObject);
function Formatdisk(drive:Char):boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function SHFormatDrive(hWnd:HWND;Drive,fntID,Options:WORD):longint;stdcall;external'shell32.dll';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Formatdisk(DriveComboBox1.Drive);
end;
function Tform1.Formatdisk(drive:Char):boolean;
var
wDrive:WORD;
rtcode:longint;
begin
wdrive:=ord(UpCase(drive))-ord('A');
rtcode:=SHFormatDrive(application.Handle,wDrive,$ffff,0);
if rtcode=-1 then
result:=false;
result:=true;
end;