[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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
0
maxb
Asked:
maxb
  • 4
  • 3
1 Solution
 
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
 
shaneholmesCommented:
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
Technology Partners: 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!

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now