Registry - Current user

  • Thread starter Thread starter Washington
  • Start date Start date
W

Washington

In my application I have following part of code:
using System;

using Microsoft.Win32;

using System.Diagnostics;

....

RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\xxx\\yyy\\")

end everything works normally..

Problem description:
----------------------
I am trying to implement the same functionality on another app and I am
receiving following error:
'HEUpdate.Registry' does not contain a definition for 'CurrentUser'



I can not se what is wrong, probably is trivial but I can not see :(



If you know where problem is, please help. Thanks.
 
Use CreateSubKey instead of OpenSubKey.

CreateSubKey will open or create the key if it doesn't already exist.
 
HEUpdate doesn't look familiar. Does that other app define, or include
a library that defines, a namespaces called HEUpdate that has a class
called Registry?

Your code is probably being interpreted incorrectly by the compiler
because the compiler thinks you're referring to a locally defined class
called Registry when in fact you want to refer to
Microsoft.Win32.Registry.

You can fix this by modifying your code to use the fully qualified name
of the Registry class:

Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\xxx\\yyy\\");

Of course, in this case you don't need the

using Microsoft.Win32;

statement at the top of your program.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top