//Inclua a unit SHELLAPI na clausula uses do seu form.
procedure DeleteDir( hHandle : THandle; Const sPath : String );
var
OpStruc: TSHFileOpStruct;
FromBuffer, ToBuffer: Array[0..128] of Char;
begin
fillChar( OpStruc, Sizeof(OpStruc), 0 );
FillChar( FromBuffer, Sizeof(FromBuffer), 0 );
FillChar( ToBuffer, Sizeof(ToBuffer), 0 );
StrPCopy( FromBuffer, sPath);
With OpStruc Do
Begin
Wnd:= hHandle;
wFunc:=FO_DELETE;
pFrom:= @FromBuffer;
pTo:= @ToBuffer;
fFlags:= FOF_NOCONFIRMATION;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
End;
ShFileOperation(OpStruc);
end;
//Exemplo:
procedure TForm1.Button1Click(Sender: TObject);
begin
DeleteDir( Self.Handle,'C:TESTE');
end;
quarta-feira, 25 de novembro de 2009
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário