0

I want add item to a key in registry and find "CreateSubKey" command but point is this command create sub key not item to a key. for example path of "Computer\HKEY_USERS.DEFAULT\Control Panel\International" has about 40 item and 3 sub key. I want add item to "\International" not sub key.

another problem is that when I want add subkey to another users in "Computer\HKEY_USERS" path ,I got error "cant access other user registry" .how could I handle that with code without login as admin in windows?

LOOK AT PICTURE: enter image description here best regards.

MHD
  • 25
  • 9

1 Answers1

0

Create the key you are interested in and then set the values:

RegistryKey rk = Registry.Users.CreateSubKey("DEFAULT\\Control Panel\\International");
rk.SetValue("a number", 42);
rk.SetValue("my string", "fiftythree");

You have to be elevated administrator to modify keys in roots other than CurrentUser. Normal users are not allowed to modify machine settings nor the settings of other users.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Plz look at picture added .do you think subkey is it work for #2 ??? i think it just add key to #1 not add item to #2 – MHD Nov 16 '21 at 12:48
  • `SetValue` sets a value in pane #2. You picture shows CurrentUser root key but your question asked about Users, make sure you are using the correct root. – Anders Nov 16 '21 at 13:23
  • if i Want add a new value to pane#2 doyou think set value could add item that ? – MHD Nov 16 '21 at 13:31
  • Yes, that method will create/modify values in pane #2 – Anders Nov 16 '21 at 14:19