Solved

Make app undeletable

Posted on 2004-04-05
7
240 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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