SHFileOperation(删除文件,像windows一样的提示是否删除到回收站)
uses shellapi;
procedure DeleteFileForApi(aFilePath: string);
var
T: TSHFileOpStruct;
LFilePath: string;
begin
//inherited;
LFilePath := aFilePath;
if fileexists(LFilePath) then
begin
with T do
begin
Wnd := 0;
wFunc := FO_DELETE;
pFrom := Pchar(LFilePath + #0);
pTo := nil;
fFlags := FOF_ALLOWUNDO or FOF_SIMPLEPROGRESS; //标志表明允许恢复,FOF_NOCONFIRMATION + FOF_NOERRORUI 无须确认并不显示出错信息
hNameMappings := nil;
lpszProgressTitle := '正在删除文件';
fAnyOperationsAborted := False;
end;
SHFileOperation(T);
end;
end;