Solved

force to open file

Posted on 2014-01-29
5
682 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 26

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 26

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 26

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

856 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