Solved

File restrict, lock.

Posted on 2014-09-26
4
211 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
4 Comments
 
LVL 26

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now