How can I prevent a registry key from deletion ?? I want to have my application store passwords of the users in a registy key ... so I want to prevent users from deleting the registry key manually.

i don't think you can, nor do I think you should try. It's my registry and if I don't want something in there, I should be able to delete it.

So where should I store the password so that it may not be deleted by anyone.

well, to make registry access read only you could log into your windows without admin rights :P
another thing maybe would be to store that data in a file and fiddle with the security rights of it (right click file -> choose security tab) and modify these to have some (password protected) user have full rights on these and the rest (including you) have only read access :S

On the other hand what you wanna do there sounds quite impossible cause the currenty logged in user (which has the rights to install the application) will also have the corresponding file access rights on his system, maybe you wanna consider proctecting your file by some system driver, that monitors access to the file and prevents its deletion...

Is it the users password or the application password? Its going to be tricky. Best place would be isolated storage and possibly some encryption but you wont stop a determined person finding it.

I would have to ask why you have the requirement. It is obviously not your pc so why wont you let me (for example) do whatever i want to my own pc? If it is crucial to have this information then store it where the average person cannot accidently delete it and make it known in the helpfile or whatever that they remove it at their own risk. You can only go so far at protecting things on other peoples pcs. It is their own after all. Its the same with anything else. I guess car manufacturers have hidden the fuel pump from the average driver, but if you are determined to remove it, dont complain when the car wont start.

This article has been dead for over six months. Start a new discussion instead.