unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls
{<== NICHT VERGESSEN!!};
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
Flags: FILEOP_FLAGS): Integer;
var
FromPath, ToPath: AnsiString;
SHFileOpStruct: TSHFileOpStruct;
begin
FromPath := aFrom + #0#0;
ToPath := aTo + #0#0;
with SHFileOpStruct
do
begin
Wnd := 0;
wFunc := aOperation;
pFrom := PAnsiChar(FromPath);
if ToPath <> '
'
then
begin
pTo := PAnsiChar(ToPath)
end else begin // target available
pTo :=
nil;
end;
// target not available
fFlags := Flags;
end;
// structure
Result := SHFileOperationA(SHFileOpStruct);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoFileWork(FO_COPY, '
aktuelle Datei (Pfad + Name)', '
neue Datei (Pfad + Name)', FOF_NOCONFIRMATION);
end;
end.