Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 703
  • Last Modified:

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

Regards
0
johnnyex
Asked:
johnnyex
  • 3
  • 2
1 Solution
 
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:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20950232.html
0
 
johnnyexAuthor Commented:
this is not the same problem I don't have problem with copy but open I use
http://www.sqlite.org/pragma.html#pragma_locking_mode

Is there any delphi solution to workaround that without copying database file to another location?
0
 
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.
0
 
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 :(
0
 
Sinisa VukCommented:
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...
https://code.google.com/p/sqlite3delphi/
http://synopse.info/fossil/wiki/Synopse+OpenSource
http://docwiki.embarcadero.com/RADStudio/XE5/en/Tutorial:_Connecting_to_a_SQLite_Database_%28Delphi%29
...using this high level components is easy - just like other database related component
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now