-
Jan 20th, 2014, 06:03 PM
#1
Thread Starter
New Member
Does Registry "SubKey" Exist Or Not
I have done a master search of the Forum for my answer, found a lot of Registry questions, but
none dealing in the exact manner, so I apologize if I have over looked anything.
I am in Visual Basic, within Visual Studio Ultimate 2013.
Problem involves working with the Registry.
I have no problem reading Key values, Creating, and Deleting Keys etc.
However, I cannot for the life of me figure out how to "simply" dictate if a "SubKey" exists, ....or not.
That's it.
Nothing fancy, nothing above, nothing beyond.
As an example:
When my VB program starts, I want it to check for the "existence" of a "SubKey" entitled, "my_prog_name"
HKEY_CLASSES_ROOT\*\shell\my_prog_name
If it exists, I would like to be returned a "1", or, "True", etc.
If it does not exist, "0", or "False".
I am not looking for a Key, "Value", ...just if a certain "SubKey" Exists or not.
You get the picture, just like in "old days" VB programming, sweet and simple.
It's the little things, sometimes, that can be the most hassle.
Any help is greatly appreciated.
Thank you.
-
Jan 20th, 2014, 06:22 PM
#2
Re: Does Registry "SubKey" Exist Or Not
Are you saying that you want to know whether that key exists at any level at all under a particular hive? If so then you'd need to do a recursive search. At each level, you can call OpenSubKey on your Registrykey object. It will return a RegistryKey object if the subkey exists and Nothing if it doesn't.
Last edited by jmcilhinney; Jan 20th, 2014 at 07:29 PM.
Reason: Removed superfluous word.
-
Jan 20th, 2014, 07:15 PM
#3
Re: Does Registry "SubKey" Exist Or Not
You get the picture, just like in "old days" VB programming, sweet and simple.
I don't know what you call the old days but VB programming existed long before the Registry did and I certainly don't remember it ever being sweet and simple!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jan 20th, 2014, 09:32 PM
#4
Thread Starter
New Member
Re: Does Registry "SubKey" Exist Or Not
Update:
Figured it out.
It wasn't a broad search I was after, I was looking at a "specific" Registry location for the existence of a "specific" Key.
Thanks to all for the help.
Code:
Dim regVersion As Microsoft.Win32.RegistryKey
regVersion = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("*\shell\my_prog_name", True)
If regVersion Is Nothing Then
MsgBox("0")
Else
MsgBox("1")
End If
-
Jan 20th, 2014, 09:39 PM
#5
Re: Does Registry "SubKey" Exist Or Not
Originally Posted by bigreid
Update:
Figured it out.
It wasn't a broad search I was after, I was looking at a "specific" Registry location for the existence of a "specific" Key.
Thanks to all for the help.
Code:
Dim regVersion As Microsoft.Win32.RegistryKey
regVersion = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("*\shell\my_prog_name", True)
If regVersion Is Nothing Then
MsgBox("0")
Else
MsgBox("1")
End If
Well, well... I rarely use the Registry and I didn't know that the RegistryKey class supported wildcards. I've learned something new.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|