Registry Reading

F

fniles

In my case, I have registry entries with multiple Key values, like the
following
[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\A]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\B]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\C]

I would like to loop thru MyApp\MySection\Data to get to entries A,B and C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

arr = GetAllSettings("MyApp", "MySection\Data") --> this gives me the string
Values for Data, not the Key value A,B, and C

Is there a way to loop thru to get to each Key Entry ?

Thanks.
 
J

Joseph Bittman MVP MCSD

Sept. 5, 2006

I don't usually handle the registry, but did you try something similar to
this:

imports microsoft.win32

'code section
Registry.CurrentUser.OpenSubKey("...your path to the Data node",
False).GetSubKeyNames()

The "false" parameter is whether you are going to want to write to this
registry key. Intellisense states that GetSubKeyNames returns a String()
collection of sub-keys. You could then cycle through these, and I would
think it would contain your A, B, C nodes.

Hopefully this helps!
--
Joseph Bittman
Microsoft Certified Solution Developer
Microsoft Most Valuable Professional -- DPM

Web Site/Blog: http://CactiDevelopers.ResDev.Net/
 
P

Phill W.

fniles said:
I would like to loop thru MyApp\MySection\Data to get to entries A,B and C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

I'd do exactly that - loop through them - as in:

Dim sKeys() As String : sKeys _
= Split( "A,B,C", "," )
Dim sValues() As String
ReDim sValues( UBound( sKeys ) )

Dim iIdx As Long
For iIdx = 0 To UBound( sKeys )
sValues( iIdx ) = GetSetting( "MyApp" _
, "MySection\Data\" & sKeys( iIdx ) )
Next

HTH,
Phill W.
 
F

fniles

When I do the following, it tells me that "CurrentUser is not a member of
Registry"

Imports System
Imports Microsoft.Win32

Dim names As String() = Registry.CurrentUser.OpenSubKey("...your path to the
Data node", False).GetSubKeyNames()

The following also gave me the same error
Dim rkCurrentUser As RegistryKey = Registry.CurrentUser

What am I missing ? Thank you.

Sept. 5, 2006

I don't usually handle the registry, but did you try something similar to
this:

imports microsoft.win32

'code section
Registry.CurrentUser.OpenSubKey("...your path to the Data node",
False).GetSubKeyNames()

The "false" parameter is whether you are going to want to write to this
registry key. Intellisense states that GetSubKeyNames returns a String()
collection of sub-keys. You could then cycle through these, and I would
think it would contain your A, B, C nodes.

Hopefully this helps!
--
Joseph Bittman
Microsoft Certified Solution Developer
Microsoft Most Valuable Professional -- DPM

Web Site/Blog: http://CactiDevelopers.ResDev.Net/

fniles said:
In my case, I have registry entries with multiple Key values, like the
following
[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\A]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\B]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\C]

I would like to loop thru MyApp\MySection\Data to get to entries A,B and
C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

arr = GetAllSettings("MyApp", "MySection\Data") --> this gives me the
string
Values for Data, not the Key value A,B, and C

Is there a way to loop thru to get to each Key Entry ?

Thanks.
 
F

fniles

When I do the following, it tells me that "CurrentUser is not a member of
Registry"

Imports System
Imports Microsoft.Win32



Dim rkCurrentUser As RegistryKey = Registry.CurrentUser

What am I missing ? Thank you.

Cor Ligthert said:
Fniles,

http://msdn.microsoft.com/library/d...tml/frlrfmicrosoftwin32registryclasstopic.asp

There is a registry class, this is not anymore as VB6. You get all allowed
access to the registry.

Be aware that the Open sometimes wil fail. I use than simple Create than I
get the same result in VB2003.

I hope this helps,

Cor


fniles said:
In my case, I have registry entries with multiple Key values, like the
following
[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\A]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\B]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\C]

I would like to loop thru MyApp\MySection\Data to get to entries A,B and
C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

arr = GetAllSettings("MyApp", "MySection\Data") --> this gives me the
string
Values for Data, not the Key value A,B, and C

Is there a way to loop thru to get to each Key Entry ?

Thanks.
 
F

fniles

Pls ignore my previous reply. I named my solution and project "Registry",
that's why I got the error I mentioned.
I changed the name of the solution and project to something other than
"Registry" and it now works.
Thanks a lot.

Joseph Bittman MVP MCSD said:
Sept. 5, 2006

I don't usually handle the registry, but did you try something similar to
this:

imports microsoft.win32

'code section
Registry.CurrentUser.OpenSubKey("...your path to the Data node",
False).GetSubKeyNames()

The "false" parameter is whether you are going to want to write to this
registry key. Intellisense states that GetSubKeyNames returns a String()
collection of sub-keys. You could then cycle through these, and I would
think it would contain your A, B, C nodes.

Hopefully this helps!
--
Joseph Bittman
Microsoft Certified Solution Developer
Microsoft Most Valuable Professional -- DPM

Web Site/Blog: http://CactiDevelopers.ResDev.Net/

fniles said:
In my case, I have registry entries with multiple Key values, like the
following
[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\A]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\B]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\C]

I would like to loop thru MyApp\MySection\Data to get to entries A,B and
C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

arr = GetAllSettings("MyApp", "MySection\Data") --> this gives me the
string
Values for Data, not the Key value A,B, and C

Is there a way to loop thru to get to each Key Entry ?

Thanks.
 
F

fniles

Pls ignore my previous reply. I named my solution and project "Registry",
that's why I got the error I mentioned.
I changed the name of the solution and project to something other than
"Registry" and it now works.
Thanks a lot.

Cor Ligthert said:
Fniles,

http://msdn.microsoft.com/library/d...tml/frlrfmicrosoftwin32registryclasstopic.asp

There is a registry class, this is not anymore as VB6. You get all allowed
access to the registry.

Be aware that the Open sometimes wil fail. I use than simple Create than I
get the same result in VB2003.

I hope this helps,

Cor


fniles said:
In my case, I have registry entries with multiple Key values, like the
following
[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\A]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\B]

[HKEY_CURRENT_USER\Software\VB and VBA Program
Settings\MyApp\MySection\Data\C]

I would like to loop thru MyApp\MySection\Data to get to entries A,B and
C,
instead of doing the following for each Key entry:
sEntryA = GetSetting("MyApp", "MySection\Data\A")
sEntryB = GetSetting("MyApp", "MySection\Data\B")
sEntryC = GetSetting("MyApp", "MySection\Data\C")

arr = GetAllSettings("MyApp", "MySection\Data") --> this gives me the
string
Values for Data, not the Key value A,B, and C

Is there a way to loop thru to get to each Key Entry ?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top