[yunqa.de] Re: DiSqlite: How to detect active 'database connection' count

  • From: Edwin Yip <edwin.yip@xxxxxxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 14 Apr 2010 16:58:54 +0800

Hi Maurits,

Thanks for the hint, it's a good idea, I have implemented my IsFileLocked
(which is similar to yours) and I somehow didn't come up this idea, thank
you!

On Wed, Apr 14, 2010 at 4:08 PM, BCT Maurits van Rijnen <
maurits.van.rijnen@xxxxxxxxxxxxxx> wrote:

> Wouldn't it be easier to try to open the database file unshared for read
> actions, then the filesystem
> would give the status automaticly?
> Something like:
>
>
>
> function FileIsLocked(Filename: string): Boolean;
> var
>  fs: TFileStream;
> begin
>  try
>    if not FileExists(FileName) then
>       Result := False
>    else
>    begin
>      fs := TFileStream.Create(FileName, fmOpenRead or
> fmShareExclusive);
>      try
>        Result := FALSE;
>      finally
>        fs.Free;
>      end;
>    end;
>  except
>    Result := TRUE;
>  end;
> end; // function FileIsLocked
>
>
>
>
> Maurits van Rijnen
> R & D Ontwikkelaar
> Value by IDT & Capture Solutions
>
>
> -----Oorspronkelijk bericht-----
> Van: yunqa-bounce@xxxxxxxxxxxxx [mailto:yunqa-bounce@xxxxxxxxxxxxx]
> Namens Delphi Inspiration
> Verzonden: woensdag 14 april 2010 9:59
> Aan: yunqa@xxxxxxxxxxxxx
> Onderwerp: [yunqa.de] Re: DiSqlite: How to detect active 'database
> connection' count
>
> At 13:08 11.04.2010, Edwin Yip wrote:
>
> >Is it possible to know if there is active connection to a Sqlite
> database file? I know I can use a flag field in the DB, but this can
> detect connections established by other programs. Thank you.
>
> As I understand your question, you want to know if another program has a
> particular SQLite database file open?
>
> DISQLite3 does not have a function to answer this question as it is not
> interested in its answer. It is concerned only if another process holds
> a lock on a database file, in which case it returns SQLITE_LOCKED.
>
> To find out which application(s) have opened a particular file or
> folder, you may use SysInternal's Process Explorer.
>
> Ralf
>
> _______________________________________________
> Delphi Inspiration mailing list
> yunqa@xxxxxxxxxxxxx
> //www.freelists.org/list/yunqa
>
>
>
>
>
>
> _______________________________________________
> Delphi Inspiration mailing list
> yunqa@xxxxxxxxxxxxx
> //www.freelists.org/list/yunqa
>
>
>
>


-- 
Best Regards,
Edwin Yip

Mind Mapping is as Effortless as Typing
http://www.InnovationGear.com

Other related posts: