Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#3

Re: Verzeichnisse kopieren mit ShFileOperation erzeugt Fehle

  Alt 9. Jul 2008, 20:35
Hallo Matthias,

hast du es schon so probiert?

Delphi-Quellcode:
function CopyDir(const fromDir, toDir: string): Boolean;
// für Widestring-Namen ist ShFileOperationW() zu verwenden
var
  fos: TSHFileOpStruct;
begin
  ZeroMemory(@fos, SizeOf(fos));
  with fos do
  begin
    wFunc := FO_COPY;
    fFlags := FOF_FILESONLY;
    pFrom := PChar(fromDir + #0);
    pTo := PChar(toDir);
  end;
  Result := (0 = ShFileOperation(fos));
end;
Aufruf so:
Delphi-Quellcode:
copydir('D:\Memotest.bmp', 'D:\XXXMEO.BMP');
// MS: Use fully-qualified paths.
// Using relative paths is not prohibited, but can have unpredictable results.
@Christian:
WinSDK :: SHFILEOPSTRUCT
  • For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES.
  • Pack multiple names into the pTo string in the same way as for pFrom.

Ohne das Flag wird der Leerstring wohl nicht benötigt.

Freundliche Grüße
  Mit Zitat antworten Zitat