Hello...
It can be much more convenient than scanning the whole "Local_Machine
\Software" as you know where to look for your value:
masterKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\781")
You "created" a subkey instead of "opening" one; and you didn't look
for your entry in "SOFTWARE\781".
It should be better now.
Else if you really want to scan, you can search with a recursive
function on the subkeys, but you're prone to errors. (You never know
what's in the registry.)
On 28 août, 13:04, "[email protected]"
<[email protected]> wrote:
> Hi all,
>
> I would am trying to develop an application that will search for a
> REG_SZ Key in the registry and print its value on to the screen.
>
> I have got this partly working. In HKEY_LOCAL_MACHINE\SOFTWARE\781 I
> created a REG_SZ entry called hell and given it the value of sausages.
> A bit random I know.
>
> When I run my program if i set the path in the code to
> HKEY_LOCAL_MACHINE\SOFTWARE\781 it will print the value sausages on
> the console.
>
> However if i set the path to HKEY_LOCAL_MACHINE\Software it won't find
> the value.
>
> I want the program to search through everything in the registry within
> HKEY_LOCAL_MACHINE\Software. how would I go about doing this. Below is
> the code that I currently have.
>
> private void btnRegedit_Click(object sender, EventArgs e)
> {
> RegistryKey masterKey = Registry.LocalMachine.CreateSubKey
> (@"SOFTWARE\\");
> if (masterKey == null)
> {
> Console.WriteLine("Null Masterkey!");
> }
> else
> {
> Console.WriteLine("Hell = {0}", masterKey.GetValue
> ("Hell"));
> }
> masterKey.Close();
> }
>
>
>
> }- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -