Accessing registry key that does not exist

xdscheetos

Member
Joined
Nov 11, 2003
Messages
6
Im 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
 
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")
 
Last edited by a moderator:
Back
Top