implementation{$R *.DFM} function SHFormatDrive(Hwnd:HWND;Drive:Integer;Size:Uint;Action:Integer):Integer; stdcall;external 'shell32.dll' name 'SHFormatDrive';function FormatDrive(Drive,Action:Integer):Integer; begin Result:=SHFormatDrive(Application.Handle,Drive,0,Action); end;procedure TForm1.Button1Click(Sender: TObject); begin FormatDrive(0,1); end;
1、先声明下面一个函数: function SHFormatDrive(Hwnd:HWND;Drive:Integer;Size:Uint;Action:Integer):Integer; stdcall;external 'shell32.dll' name 'SHFormatDrive'; 说明:1、Hwnd:窗口所有者的句柄 2、Drive:所有格式化的对象:0指a驱;1指b驱;2指c盘... 3、Size:暂时无用 4、Action:0:快速格式化;1:全面格式化;2:格式化时传送系统,即:sys a(b,c) 2、上述函数参数太多,可以再次进行包装即: function FormatDrive(Drive,Action:Integer):Integer; begin Result:=SHFormatDrive(Application.Handle,Drive,0,Action); end; 说明:只需要填写两个参数 3、用法: 1、快速格式化A盘: FormatDrive(0,0); 2、全面格式化A盘: FormatDrive(1,0); 3、格式化A盘时带系统: FormatDrive(2,0);
或者调用系统对话框: procedure TForm1.Button1Click(Sender: TObject); begin winexec('RunDLL32.exe Shell32.dll,SHFormatDrive',sw_shownormal); end;
function SHFormatDrive(Hwnd:HWND;Drive:Integer;Size:Uint;Action:Integer):Integer;
stdcall;external 'shell32.dll' name 'SHFormatDrive';function FormatDrive(Drive,Action:Integer):Integer;
begin
Result:=SHFormatDrive(Application.Handle,Drive,0,Action);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FormatDrive(0,1);
end;
function SHFormatDrive(Hwnd:HWND;Drive:Integer;Size:Uint;Action:Integer):Integer;
stdcall;external 'shell32.dll' name 'SHFormatDrive';
说明:1、Hwnd:窗口所有者的句柄
2、Drive:所有格式化的对象:0指a驱;1指b驱;2指c盘...
3、Size:暂时无用
4、Action:0:快速格式化;1:全面格式化;2:格式化时传送系统,即:sys a(b,c)
2、上述函数参数太多,可以再次进行包装即:
function FormatDrive(Drive,Action:Integer):Integer;
begin
Result:=SHFormatDrive(Application.Handle,Drive,0,Action);
end;
说明:只需要填写两个参数
3、用法:
1、快速格式化A盘: FormatDrive(0,0);
2、全面格式化A盘: FormatDrive(1,0);
3、格式化A盘时带系统: FormatDrive(2,0);
procedure TForm1.Button1Click(Sender: TObject);
begin
winexec('RunDLL32.exe Shell32.dll,SHFormatDrive',sw_shownormal);
end;
我关注……………………