Solved

force to open file

Posted on 2014-01-29
5
666 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 25

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 25

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 25

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countX 22 70
word0 challenge 4 54
How does Google get such fast response times? 5 126
oracle query help 18 78
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now