Autor Beitrag
AScomp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 162


Delphi 5, Delphi 7, Delphi 2007, Delphi 2009, Delphi XE, Delphi 10 Seattle
BeitragVerfasst: Mo 05.04.10 00:47 
Hallo,

folgende Funktion verwende ich, um eine Datei in den Papierkorb zu verschieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function DeleteFileWithUndo(sFileName: String): boolean;
var
  fos: TSHFileOpStruct;
begin
  FillChar(fos, SizeOf(fos), 0);
  with fos do begin
    wFunc  := FO_DELETE;
    pFrom  := PChar(sFileName);
    fFlags := FOF_ALLOWUNDO
              or FOF_NOCONFIRMATION
              or FOF_SILENT;
  end;
  Result := (0 = ShFileOperation(fos));
end;


Das funktionierte bisher einwandfrei, aber seit Delphi 2010 scheint das nicht mehr zu funktionieren. Result ist immer false, manchmal hängt das Programm auch sekundenlang beim Aufruf von ShFileOperation(fos). Die Dateien werden nicht in den Papierkorb verschoben.

sFileName kommt korrekt als Unicode-String an, die Dateien existieren also.

Danke schonmal für jeden Tipp!

Gruß

Andy
AScomp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 162


Delphi 5, Delphi 7, Delphi 2007, Delphi 2009, Delphi XE, Delphi 10 Seattle
BeitragVerfasst: Mo 05.04.10 00:54 
Hab's rausgefunden: pFrom muss ein nullterminierter String sein.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 05.04.10 01:36 
Doppelt nullterminierend. Siehe Hilfe.