RecycleFile()删除文件到回收站
{删除文件到回收站}
//if fileexists('d:\a.txt') then RecycleFile('d:\a.txt' + #0);
// uses shellapi;
function RecycleFile(sFileName: string): Boolean;
var
FOS: TSHFileOpStruct;
begin
FillChar(FOS, SizeOf(FOS), 0);
with FOS do
begin
wFunc := FO_DELETE;
pFrom := PChar(sFileName);
fFlags := FOF_ALLOWUNDO;
end;
Result := (SHFileOperation(FOS) = 0);
end;
//if fileexists('d:\a.txt') then RecycleFile('d:\a.txt' + #0);
// uses shellapi;
function RecycleFile(sFileName: string): Boolean;
var
FOS: TSHFileOpStruct;
begin
FillChar(FOS, SizeOf(FOS), 0);
with FOS do
begin
wFunc := FO_DELETE;
pFrom := PChar(sFileName);
fFlags := FOF_ALLOWUNDO;
end;
Result := (SHFileOperation(FOS) = 0);
end;