Solved

File restrict, lock.

Posted on 2014-09-26
4
222 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

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 …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…

737 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