Solved

File restrict, lock.

Posted on 2014-09-26
4
221 Views
Last Modified: 2015-02-12
Delphi XE,

I need to protect some files from deleting, files blong to my user mode application.
Need to put code in service which will protect certain files from delete or modification, but still file must be accessed to my app fully not others.
Please advice.
0
Comment
Question by:Ian Simonv
[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
4 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 250 total points
ID: 40347705
it is quite easy. Just open files in exclusive mode (using fmShareExclusive) on app startup and that is it.
Little problem is what are your files and how your app access them.
...
var
  fs: TFileStream;
  v: byte;
 
begin
  fs := TFileStream.Create('C:\myfile' fmOpenReadWrite or fmShareExclusive);
  try
    fs.Seek(0, soEnd);
....
  finally
    fs.Free;
  end;

Open in new window


more file open flags:
http://www.delphibasics.co.uk/Method.asp?NameSpace=System.IO&Class=File&Type=Class&Method=Open
https://helloacm.com/file-opening-mode-for-tfilestream-in-delphi/


.... inside of your app you can share pointer/handle to opened file.
(pointer for TFileStream or handle for FileOpen function)
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 250 total points
ID: 40347727
is that while your app is running or also when it's down ?

if also when the app is down, then you'll have to use setup security on the folder containing those files
easiest is to assign access levels to certain groups and then placing the specific accounts in the correct group

you'll network admin for that in a company
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

Title # Comments Views Activity
Reccomended programming language for client-server applications 12 160
Delphi problems to abort a printjob 9 34
Using Third Party DLL with Access VBA 14 51
Programming Codes 2 39
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

756 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