Solved

Make app undeletable

Posted on 2004-04-05
7
241 Views
Last Modified: 2008-02-26
Hi there,
How do I lock files to make them undeletable at the file level? I saw another protection app do this (something with NTFS?)

Thanks for any pointers!
Max
0
Comment
Question by:maxb
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10761866
FileSetAttr('MyFile.sys', faReadOnly or faSysFile);

FileSetAttr returns zero if the function was successful. Otherwise the return value is a Windows error code.


Shane
0
 

Author Comment

by:maxb
ID: 10761899
so where would this go on c:\test.exe ? so it can't be deleted unless its allowed (by running the app again and allowing deletion)
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
ID: 10761944
var
 Attributes: Integer;
begin
 //can't delete
 Attributes:= Attributes and faReadOnly or faSysFile;
 FileSetAttr('c:\test.exe ', Attributes);
 //can delete
 Attributes:= Attributes and not faReadOnly or faSysFile;
 FileSetAttr('c:\test.exe ', Attributes);
end;

Shane
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:maxb
ID: 10762004
Will this work on all win98+ ?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10762016


Yes! - This is basic File manipulation stuff. Did you test it?

Shane
0
 

Author Comment

by:maxb
ID: 10762090
I'm not able to test it... trust you though :)
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10762117
OK, well let me know if you have any trouble...

Shane
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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