cannot write to the registry key

前端 未结 4 2296
耶瑟儿~
耶瑟儿~ 2020-12-05 13:25

I am getting error cannot write to the registry key when i am trying to save my keys in the registry .

//Here is my code .

Note : I tried to run as an Admin

4条回答
  •  抹茶落季
    2020-12-05 13:49

    Try this:

    RegistryKey skms = SoftwareKey.OpenSubKey(RegistryKeyName, true);
    

    The second parameter should be set to true if you need write access to the key.

    -EDIT-

    On 64-bit system, you can try this (if you are using .Net 4):

    private readonly RegistryKey SoftwareKey = 
        RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).
        OpenSubKey("SOFTWARE");
    

提交回复
热议问题