Удалить каталог со всем содержимым 4
procedure TForm1.deletedirectory(dir: string);
var
sh: SHFILEOPSTRUCT;
st: string;
sr: tsearchrec;
pst: pchar;
begin
if findfirst(dir, faDirectory, sr) = 0 then
begin
//added by me
dir := longtoshortfilename(dir);
//original code
sh.Wnd := Form1.handle;
sh.wFunc := FO_DELETE;
Pst := StrAlloc(Length(dir {sr.Name}) + 1);
StrPLCopy(Pst, dir {sr.Name}, Length(dir {sr.Name}) + 1);
sh.pFrom := pst;
sh.pTo := nil;
sh.fFlags := FOF_NOCONFIRMATION or FOF_SILENT;
sh.hNameMappings := nil;
sh.lpszProgressTitle := nil;
SHFileOperation(sh);
StrDispose(Pst);
end;
findclose(sr);
end;
|
|