I'm trying to detect if an INI file is open by another program, but the way
I normally do this is not working.
 
// open the file for write and keep it open to test
Assign(myfile,'my.ini');
Rewrite(myfile);
   
{$i-}
Assign(myfile2, 'my.ini';
Rewrite(myfile2);    //try to open it for write again
Writeln(ioresult);    //correctly displays a 5 for access denied
{$i+}
 
 
{$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?
 
Any ideas how to keep retrying to access with ini file until it is either
successful or a timeout?
 
James
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to