unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, shellapi, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DoFileWork(
aWnd: HWND; aOperation: UINT; aFrom, aTo: TStrings; Flags: FILEOP_FLAGS): Integer;
var
I: Integer;
FromPath, ToPath:
string;
SHFileOpStruct: TSHFileOpStruct;
begin
FromPath := '
';
for I := 0
to aFrom.Count - 1
do
FromPath := FromPath + aFrom.Strings[I] + #0;
FromPath := FromPath + #0;
if Assigned(aTo)
then
begin
ToPath := '
';
for I := 0
to aTo.Count - 1
do
ToPath := ToPath + aTo.Strings[I] + #0;
ToPath := ToPath + #0;
if aTo.Count > 0
then
Flags := Flags
or FOF_MULTIDESTFILES;
end;
with SHFileOpStruct
do
begin
Wnd := aWnd;
wFunc := aOperation;
pFrom := PChar(FromPath);
if Assigned(aTo)
then
begin
pTo := PChar(ToPath)
end else begin // target available
pTo :=
nil;
end;
// target not available
fFlags := aFlags;
//undeclared identifier
end;
// structure
Result := SHFileOperation(SHFileOpStruct);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoFileWork(Self.Handle, FO_DELETE, strlFiles,
nil, FOF_ALLOWUNDO);
end;
end.