Solved

force to open file

Posted on 2014-01-29
5
687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: 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

Title # Comments Views Activity
Using Third Party DLL with Access VBA 14 68
I could not set window to top 4 63
BATCH to EXE Converter 2 99
Why is initMap returning "not a function" error. 3 126
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 a problem I had getting the GPS LocationListener working.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

752 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