James Richters via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am
Do., 29. Apr. 2021, 03:13:

> {$i-}
>
> Log_Ini := TIniFile.Create(‘my.ini’);   // blows up with 217
>
> Writeln(ioresult);
>
> {$i+}
>
>
>
> The error I get is:
>
> An unhandled exception occurred at $005A57D0:
>
> EFOpenError: Unable to open file "LOG.INI": The process cannot access the
> file because it is being used by another process.
>
>
>
> I want to just keep trying to open it until the other process is done.  I
> don’t understand why it’s an ‘unhandled exception’ when I was handling it.
>
> I guess TiniFile.Create has an {$i+} in it and so that’s why it’s blowing
> up
>
TIniFile does not make use of IOResult, because it's from the Delphi time,
not the TP time. Thus you need to use Object Pascal exception handling:

=== code begin ===

try
  Log_ini := TIniFile.Create('myini.ini');
except
  on e: EFOpenError do
    // handle this to decide whether to retry
  on e: Exception do
    // handle other problems
end;

=== code end ===

Regards,
Sven

>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to