Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
Delphi 10.4 Sydney
|
AW: Fehlermeldung bei Schreiben nach CSIDL_APPDATA
15. Apr 2011, 22:28
vorübergehend habe ich es jetzt erst mal so geändert:
Delphi-Quellcode:
implementation
var
inUseReadFileName: string='';
inUseWriteFileName: string='';
function TStrIniFile.isFileReadyForRW: boolean;
var
r,w: boolean;
begin
RESULT:=true;
r:=UpperCase(FileName)=UpperCase(inUseReadFileName);
w:=UpperCase(FileName)=UpperCase(inUseWriteFileName);
if (r or w) then
begin
repeat
RESULT:=false;
until ((inUseReadFileName='') and (inUseWriteFileName=''));
RESULT:=true;
end;
end;
function TStrIniFile.LoadFile : boolean;
var
f: TextFile;
u: string;
errorCode: Integer;
begin
RESULT:=false;
if IniFileExists then
begin
if isFileReadyForRW then <--
begin
AssignFile(f,FileName);
{$I-} Reset(f); {$I+}
errorCode:= IOResult;
if errorCode=0 then
begin
RESULT:=true;
inUseReadFileName:=FileName; <--
while not eof(f) do
begin
readln(f,u);
if isIniRow(u) then addItem(u);
end;
closeFile(f);
end;
if not RESULT then
MessageDlg(application.ExeName+': '+FileName+' ['+sysErrorMessage(errorCode)+'].',mtWarning,[mbOk],0);
end;
end;
inUseReadFileName:=''; <--
end;
function TStrIniFile.SaveFile : boolean;
var
f: TextFile;
i, errorCode: Integer;
begin
RESULT:=false;
if FileName<>'' then
begin
if isFileReadyForRW then <--
begin
AssignFile(f,FileName);
{$I-} Rewrite(f); {$I+}
errorCode:= IOResult;
if errorCode=0 then
begin
RESULT:=true;
inUseWriteFileName:=FileName; <--
for i:=0 to Count-1 do
begin
if i>0 then
if posIS[i]<0 then writeln(f);
writeln(f,item[i]);
end;
closeFile(f);
end;
if not RESULT then
MessageDlg(application.ExeName+': '+FileName+' ['+sysErrorMessage(errorCode)+'].',mtWarning,[mbOk],0);
end;
end;
inUseWriteFileName:=''; <--
end;
|
|
Zitat
|