Solved

Make app undeletable

Posted on 2004-04-05
7
238 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

16 Experts available now in Live!

Get 1:1 Help Now