Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create registry key, not the usual [closed]

Tags:

c#

.net

Been googling but I cant find out how to create a registry key itself, not a subkey string value as is seen in all the tutorials. The registry is like a tree with branches and leaves, I want to create a new branch and add a leaf

|tree
|-branch
|  |-my branch
|-branch

Thanks for any help

More info to make it clearer as i'm being pointed to what I dont need ;)

you click on one of the registry keys, next to it is an arrow pointing down, you click it and you get more keys maybe with another arrow pointing down for more ketys, well thats what I'm trying to create a "folder" looking thing. I'm not sure how else I can explain but CreateSubKey does nothing like that for me:

Key = Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsof\game\addons\myaddons");

Now, when I check it there is no folder-like icon named myaddons

like image 231
ace007 Avatar asked Nov 01 '12 20:11

ace007


People also ask

How do I create an empty registry key?

If you're creating a new registry key, right-click or tap-and-hold on the key it should exist under and choose New > Key. Name the new registry key and then press Enter.

How do I delete a registry entry with a .reg file?

To delete a registry path with all the subkeys, put a hyphen (-) in from of the registry path in the . reg file. To delete a single subkey put a hyphen (-) after the equals sign following the DataItemName in the . reg file.


1 Answers

Not sure if this is what you are trying to do, but you may use Registry.SetValue(string keyName, string valueName, object value, RegistryValueKind valuekind) to create Keys/Subkeys and its values.

Example

Registry.SetValue(@"HKEY_CURRENT_USER\Software\Picrofo Software\", "", ""); //Tree
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Picrofo Software\Subkey", "", ""); //Branch
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Picrofo Software\Subkey", "Value Name", "Value", RegistryValueKind.String); //Branch's value
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Picrofo Software\Another Subkey", "", ""); //Branch

This will create a key in HKEY_CURRENT_USER\Software\ with the name Picrofo Software. Then, creates a subkey in the key we've created with the name Subkey and sets a value of name Value Name and its value Value of type String. Finally, creates another subkey in Picrofo Software with the name Another Subkey which has no specific value.

Example

Thanks,
I hope you find this helpful :)

like image 56
Picrofo Software Avatar answered Sep 26 '22 18:09

Picrofo Software