Stopping A File From Being Deleted

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

Hey There,
Is there a way to write code that will protect a file such that
when a user tries to delete it, it will be protected with the "Cannot
delete 'xyz': Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use.". Also, how
would you programatically do the reverse? Have a code remove what
protection there is from a file that has that set?

Thank you for the prompt response,
Jay
(patelj27b at gmail dot com)


P.S. I just want to thank all the people out there that have been
prompt in answering my previous questions. It is great to know that
there is always a source out there that can help me gain a better
insight into Windows C++ programming.
 
Jay said:
Hey There,
Is there a way to write code that will protect a file such that
when a user tries to delete it, it will be protected with the "Cannot
delete 'xyz': Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use.". Also, how
would you programatically do the reverse? Have a code remove what
protection there is from a file that has that set?

There's actually about 5 or 6 different ways to do this, depending on how
much control you need to have and what programming model you are using
(Win32, MFC, COM, C++/CLI).

Here's the link to the start of one of the relevant MSDN Library sections:

http://msdn.microsoft.com/library/d...cauthz/security/access_control.asp?frame=true

It's not terribly difficult once you learn the terminology and concepts, but
it can be pretty overwhelming at first.

Sean
 
Sean,
Thanks for the link, it helped me get something running that I
wanted, but I have two questions:
1). When I reboot the machine, the Access Rights go back to the
previous settings, how do I get the modified Access Rights to stick
across reboots?
2). Also, is this information kept in the registry? If so, where in
the registry is it kept?

Thanks,
Jay
(patelj27b at gmail dot com)
 
Back
Top