TIniFile/ TMemIniFile benötigen die Datei exklusiv. Diese wird vermutlich aber von einem anderen Prozess benutzt.
Delphi-Quellcode:
procedure Wait (var N: integer);
var
fTime: Cardinal;
begin
fTime:= GetTickCount;
repeat until (GetTickCount-fTime) > 500;
N:= N+1;
end;
function IsFileReadyForOpen (const FileName: string): boolean;
var
N, IO: integer;
F: TextFile;
begin
N:= 0;
AssignFile(F, FileName);
repeat
{$I-} Reset(f); {$I+}
IO:= IOResult;
if IO <> 0 then Wait(N);
until ((IO = 0) or (N = 10));
Result:= (IO = 0);
if Result then
closeFile(f)
else
MessageDlg(Application.ExeName+': '+FileName+' ['+SysErrorMessage(IO)+'].', mtWarning, [mbOK], 0);
end;
var
Ini : TInifile;
begin
if not IsFileReadyForOpen (Inifilename) then Exit;