Pascal

domingo, 26 de julho de 2009

Apagar um Sub Diretório no Delphi

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;


//lpszProgressTitle:=nil;


End;


ShFileOperation(OpStruc);


end;



Utilize a funçăo assim:









procedure TForm1.Button1Click(Sender: TObject);


begin


DeleteDir( Self.Handle,'C:\TESTE');


end;


Nenhum comentário:

Postar um comentário