Domanda

We have a legacy application uses the BDE. (The BDEcontinues to work surprisingly well, given its age).

There are times when our app needs to manipulate folders (Rename, move, etc.) but a .NET or .LCK file remains open in the folder, preventing that. We have been unable to find any table or query still open in our code.

Other than having our program shell to a non-BDE program and itself terminating, is there a programatic way for us to shut down the BDE, which would unlock these files.

Standard disclaimers : Yes, the BDE is dead. Yes, we should migrate to a more modern database. Yes, someday the BDE just won't work anymore. With almost 2 million lines of legacy code, migrating (even with a somewhat plug compatible platform like Sybase Advantage) isn't an inexpensive project, which is why we haven't done it yet...

È stato utile?

Soluzione

You normally don't have anything specific to do for shutting down the BDE.
All the BDE Sessions are freed in the Finalization section of DBTables. This will close everything and when the Default Session is destroyed as well it will call DbiDLLExit if needed, then DbiExit, both from the BDE unit.

Now, if you want to shutdown the BDE before, I suggest you do mimic the finalization then initialization parts of DBTables (disclaimer: limited testing, use carefully...) like:

procedure BDEKill;
begin
// from finalization
  Sessions.Free;
  Sessions := nil;
end;

procedure BDEReStart;
begin
// from initialization
  Sessions := TSessionList.Create;
  Session := TSession.Create(nil);
  Session.SessionName := 'Default'; { Do not localize }
end;

and use it like:

BDEKill;
try
  // move my folders
finally
  BDEReStart;
end;

Altri suggerimenti

Unlocking file is another possible (extreme) solution to your issue:

I suggest you to study the source code of File Unlock by opc0de.


Quote:

All too often a file cannot be deleted because it is in use by another application. This tool allows you to unlock that file for deletion.


Look and feel:

File Unlock by opc0de


Features:

  • Unlock file
  • Unlock & Delete file
  • View which processes use the file
  • Terminate the processes which uses the file

Download link:

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top