How do I check whether a user is allowed to read / write a particular registry key?

前端 未结 6 589
清歌不尽
清歌不尽 2020-12-31 08:14

Does anybody know how I can programmatically check (using C#) whether my program will be able to read / write a particular registry key (specifically: \"SOFTWARE\\Microsoft\

6条回答
  •  盖世英雄少女心
    2020-12-31 08:58

    I think you best bet is to just try to add your value to the key, and handle failure gracefully by informing the user they didn't have enough permissions to do that.

    If you're writing some sort of administrative tool that is designed to always be run by an administrator, you should indicate that in the manifest. That way your app will elevate at startup (via UAC prompt).

提交回复
热议问题