Solved

force to open file

Posted on 2014-01-29
5
684 Views
Last Modified: 2014-01-30
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
Comment
Question by:johnnyex
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Sinisa Vuk
ID: 39820192
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
 

Author Comment

by:johnnyex
ID: 39820543
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
 
LVL 27

Expert Comment

by:Sinisa Vuk
ID: 39820606
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
 

Author Comment

by:johnnyex
ID: 39821865
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
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 39822376
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question