Autor Beitrag
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 04.10.05 14:26 
Hallo
Ich hab ein Problem mit löschen von mehreren Dateien.
Hab schon alles mögliche Ausprobiert auch mit PChar und kriegs nicht gebacken.
Vieleicht erkennt einer von Euch den Fehler.
Erste Variante funktioniert Problemlos, zweitere nicht.
Fehler mit Kernl32.Dll

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
{Bei Dieser Variante funktioniert es Problemlos}

procedure TForm1.Button3Click(Sender: TObject);
var SHFileOP: TSHFileOpStruct;
   Files:String;
begin
   SHFileOp.Wnd := Handle;
   SHFileOp.wFunc := FO_DELETE;
   SHFileOp.fFlags := FOF_ALLOWUNDO;
   Files := LoeschPfad+#0;
   SHFileOp.pFrom := PChar(files);
   SHFileOperation(SHFileOp);
end;

procedure TForm1.CheckListBox1Click(Sender: TObject);
var
 i:Integer;
begin
  i:=CheckListBox1.ItemIndex;
  if CheckListBox1.State[i] = cbchecked then
  Loeschpfad:=Loeschpfad+ShelltreeView1.Path+'\'+(CheckListBox1.Items[I])+#0;
end;

{Bei der Variante krieg Ich die Fehlermeldung.}

procedure TForm1.MarkierteLoeschenClick(Sender: TObject);
var SHFileOP: TSHFileOpStruct;
    Files:String;
begin
   SHFileOp.Wnd := Handle;
   SHFileOp.wFunc := FO_DELETE;
   SHFileOp.fFlags := FOF_ALLOWUNDO;
   Files := LoeschPfad+#0;
   SHFileOp.pFrom := PChar(Files);
   SHFileOperation(SHFileOp); {Hier Fehler}
end;


procedure TForm1.BildListeClick(Sender: TObject);
var
 i:Integer;
begin
  i:=BildListe.ItemIndex;
   if BildListe.State[i] = cbchecked then
   Loeschpfad:=Loeschpfad+PfadEdit.Text+'\'+(BildListe.Items[i])+#0;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 04.10.05 18:05 
Moin!

Da die beiden Codeteile identisch sind, kann das doch nur noch an den Parametern liegen. Lass dir doch mal mit ShowMessage(files) unmittelbar vor dem Start der Systemfunktion anzeigen, was in dem String drin steht.

cu
Narses
Blackheart666 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 04.10.05 18:48 
Danke Narses
Das Mit Showmessage war ne' gute Idee aber er zeigt mir dann als Ergebnis nur den Pfad der zuletzt angehakten Datei.
In beiden Fällen.

Beim zweiten Fall wo es nicht funktioniert zeigt mir Delphi
beim Überfahren von Löschpfad in diesem Fall die drei Pfade
der Dateien an.
Also als Bsp. LoeschPfad='Datei1'#0'Datei2'#0'Datei3'#0
Ist schon seltsam.