Saving Data to Registry on Windows 7
I heard that Windows 7 restricts access to its registry, so that applications cannot write directly to it. Is this so? I am developing an application in C#, and I would like to be able to save things such as port settings, last file used, etc. between sessions. Is the registry still a good option, or is there an开发者_StackOverflowother preferred means of doing this now? Thanks.
Access to the registry has been restricted since (at least) Windows NT 4. That does not mean that you cannot write to it; it just means that you cannot write to it everywhere. Normally, writing in HKEY_CURRENT_USER
should still be possible.
The registry is still a good option for storing settings. However, you can also save yourself some work and use "application settings" instead, which are stored in an XML file in the user's profile folder. Here I asked what their advantage was over the registry, resulting in a great discussion of the pros and cons of each.
精彩评论