xdscheetos Posted November 11, 2003 Posted November 11, 2003 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 Quote
Moderators Robby Posted November 12, 2003 Moderators Posted November 12, 2003 Use ... If Not xxx = nothing then Quote Visit...Bassic Software
xdscheetos Posted November 12, 2003 Author Posted November 12, 2003 (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 November 12, 2003 by xdscheetos Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.