![]() |
[TSHFileOpStruct] AV beim löschen eines Ordners
Mit folgenden Code möchte ich einen Ordner + Inhalt löschen:
Delphi-Quellcode:
Aber es gibt in der vorletzten (+end)/ letzten (-end) Zeile eine AV... Nur warum ?
function DeleteDirectory(const AFile: string): boolean;
var Operation: TSHFileOpStruct; begin with Operation do begin wFunc := FO_DELETE; pFrom := PChar(AFile + #0); fFlags := FOF_NOCONFIRMATION or FOF_NOERRORUI; end; Result := SHFileOperation(Operation) = 0; end; PS: Es ist egal ob AFile ein schließendes "\" hat oder net... |
Re: [TSHFileOpStruct] AV beim löschen eines Ordners
Ohne es jetzt ausprobiert zu haben, aber Operation.pTo ist undefiniert, wer weiß was dort gerade drinsteht...?
|
Re: [TSHFileOpStruct] AV beim löschen eines Ordners
Die AV bekomme ich auch. Wenn ich aber das #0 weglasse, geht es.
Delphi-Quellcode:
pFrom := PChar(AFile);
|
Re: [TSHFileOpStruct] AV beim löschen eines Ordners
Hallo,
wie sieht es damit aus ?
Delphi-Quellcode:
function DeleteDirectory(const AFile: string): boolean;
var Operation: TSHFileOpStruct; szFile: array[0..255] of Char; // jaja MAXPATH oder so begin StrPCopy(szFile, AFile); StrCat(szFile, #0); with Operation do begin wFunc := FO_DELETE; pFrom := szFile; fFlags := FOF_NOCONFIRMATION or FOF_NOERRORUI; end; Result := SHFileOperation(Operation) = 0; end; Heiko |
Re: [TSHFileOpStruct] AV beim löschen eines Ordners
Zitat:
Zitat:
Zitat:
|
Re: [TSHFileOpStruct] AV beim löschen eines Ordners
Hallo Fabian,
Zitat:
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz