|
-
Feb 27th, 2007, 06:51 AM
#1
Thread Starter
New Member
[Resolved] reading reg values
I'm attempting to write an application which reads all sub keys from
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\
I am managing to retrieve all the subkey names fine, however when I want to retrieve a value from within this I get nothing.
My code is as follows:
Code:
Dim regkey As RegistryKey
regkey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall\", True)
Dim key As String
Dim test As String
For Each key In regkey.GetSubKeyNames()
test = CType(regkey.GetValue(key & "\InstallDate"), String)
TextBox2.Text = TextBox2.Text & vbCrLf & key & " - '" & test & "'"
Next
I've only tried the CType bit as I read that you need to convert a registry value to string to be able to read it.
A result is as follows
CNXT_MODEM_HDAUDIO_VEN_14F1&DEV_2BFA&SUBSYS_14F100C3 - ''
Combined Community Codec Pack_is1 - ''
Connection Manager - ''
DirectAnimation - ''
DirectDrawEx - ''
DXM_Runtime - ''
some of these obviously dont have a value for InstallDate however I know for sure that the Combined Community Codec Pack_is1 has a value for this.
Any help is gratefully appreciated.
Last edited by peteoc; Feb 27th, 2007 at 08:34 AM.
Reason: Resolved
-
Feb 27th, 2007, 07:56 AM
#2
Re: reading reg values
You can't get a value like that from the parent key. Once you have all the subkey names you have to open each one. Then you can get the InstallDate value from each of those keys. The easiest way would be like this:
Code:
Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall")
Dim subkey As RegistryKey
For Each subkeyName As String In key.GetSubKeyNames()
subkey = key.OpenSubKey(subkeyName)
TextBox1.AppendText(String.Format("Name: {0} - InstallDate:{1}{2}", _
subkeyName, _
subkey.GetValue("InstallDate"), _
Environment.NewLine))
subkey.Close()
Next subkeyName
key.Close()
-
Feb 27th, 2007, 08:12 AM
#3
Thread Starter
New Member
Re: reading reg values
cheers jmcilhinney saved me alot of time.
-
Feb 27th, 2007, 09:33 AM
#4
Thread Starter
New Member
Re: [Resolved] reading reg values
would this work with .net v1.1 as I've just found out that v2.0 will not be available on users machines and cannot be installed either.
-
Feb 27th, 2007, 10:07 AM
#5
Re: [Resolved] reading reg values
Yes, it's the same code for .NET 1.1. It's using the Microsoft.Win32 namespace after all.
-
Feb 27th, 2007, 10:09 AM
#6
Thread Starter
New Member
Re: [Resolved] reading reg values
ah cheers, just edited the references to v1.1 and its broke other stuff, will fix that. Cheers
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
|