vb.net - How do I check to see if a registry entry exists? -


i'm trying see if registry key exists. if does, on thing, if not, else. i've tried different things, far none have worked.

i've tried:

if my.computer.registry.currentuser.getvalue("mysubkey", true) nothing 

also, i've tried see if regkey var nothing. , few others can't remember.

any ideas?

thanks

to check if registry key exists can use this...

  'obtain instance of registrykey currentuser registry root.     dim rkcurrentuser registrykey = registry.currentuser   ' obtain key (read-only) , display it.    if rkcurrentuser isnot nothing       dim rktest registrykey = rkcurrentuser.opensubkey("mysubkey")        'check , make sure have something...       if rktest isnot nothing          'you have then...           rktest.close 'close it, important...       else          'you not have anything...       end if         rkcurrentuser.close 'close after done...    else       'failed instance of registry current user...    end if 

there other ways well, let me know how works out you...


Comments