force to open file

Is there a api/delphi function to open file which is locked by other app?

My exe(with full administrative privileges) cannot open even read-only file used by other process, the only method is copy this file to another location and read,open from there.

Is there any workaround without copying to read/open 'locked' file?
Need Delphi solution

Who is Participating?
Sinisa VukConnect With a Mentor Commented:
You didn't noticed that you want to access SQLite database, not file itself.
So you want to use database when another process is using it too?
You can do this using some components like this...
...using this high level components is easy - just like other database related component
Sinisa VukCommented:
How do you try to open file (show code)?
Best is to use:
fs := TFileStream.Create(sFile, fmOpenRead or fmShareDenyNone);

Open in new window

Old topic:
johnnyexAuthor Commented:
this is not the same problem I don't have problem with copy but open I use

Is there any delphi solution to workaround that without copying database file to another location?
Sinisa VukCommented:
Try to use upper code to open file stream. If you can copy database file when server is running - then upper code should work. Don't bother with copy example.
johnnyexAuthor Commented:
working with the SQLite files so use only functions from  sqlite3  dll  and not directly access  file.  I used library functions for  access the SQLite database. So I guess there is no solution for that :(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.