Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to acces and read a registry value but on some computers the key / subkey do not exist.

SO I keep getting an error message saying:

----

An unhandled exception of type 'System.NullReferenceException' occurred in dc.exe

 

Additional information: Object reference not set to an instance of an object.

----

 

Anyway of checking the existance of the key before hand ?

Or checking the result for validity ?

At the moment I get Nothing as a value when I step thru the code. Already tried testing for getype.tostring = "Nothing" .

 

 

VB.net and using the following fonctions:

Registry.LocalMachine.OpenSubKey("SOFTWARE\abc\def").GetValue("myvalue")

 

Any help is appreciated,

thanks

Posted (edited)

Thank you very much !

just what I needed :cool:

 

Feel kinda stupid now hehehe :rolleyes:

 

edit: this is the code that worked in case others need it as well...

regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\MyCie\MySubKey")

If Not (regKey Is Nothing) Then strRegKey = regKey.GetValue("keynamehere")

Edited by xdscheetos

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...