Make app undeletable

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
maxbAsked:
Who is Participating?
 
shaneholmesConnect With a Mentor Commented:
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
 
shaneholmesCommented:
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
 
maxbAuthor Commented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
maxbAuthor Commented:
Will this work on all win98+ ?
0
 
shaneholmesCommented:


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

Shane
0
 
maxbAuthor Commented:
I'm not able to test it... trust you though :)
0
 
shaneholmesCommented:
OK, well let me know if you have any trouble...

Shane
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.