Home All Groups Group Topic Archive Search About
Author
5 Sep 2006 8:51 PM
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.

Author
6 Sep 2006 3:24 AM
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/

Show quoteHide quote
"fniles" <fni***@pfmail.com> wrote in message
news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
> 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.
>
>
>
Author
6 Sep 2006 2:35 PM
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.

Show quoteHide quote
"Joseph Bittman MVP MCSD" <RyanBitt***@msn.com> wrote in message
news:OOiQeSW0GHA.4580@TK2MSFTNGP05.phx.gbl...

> 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" <fni***@pfmail.com> wrote in message
> news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
>> 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.
>>
>>
>>
>
>
Author
6 Sep 2006 2:57 PM
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.

Show quoteHide quote
"Joseph Bittman MVP MCSD" <RyanBitt***@msn.com> wrote in message
news:OOiQeSW0GHA.4580@TK2MSFTNGP05.phx.gbl...
> 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" <fni***@pfmail.com> wrote in message
> news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
>> 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.
>>
>>
>>
>
>
Author
6 Sep 2006 4:48 AM
Cor Ligthert [MVP]
Fniles,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/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


Show quoteHide quote
"fniles" <fni***@pfmail.com> schreef in bericht
news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
> 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.
>
>
>
Author
6 Sep 2006 2:36 PM
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.

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:eOG%2349W0GHA.4368@TK2MSFTNGP02.phx.gbl...
> Fniles,
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/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" <fni***@pfmail.com> schreef in bericht
> news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
>> 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.
>>
>>
>>
>
>
Author
6 Sep 2006 2:58 PM
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.

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:eOG%2349W0GHA.4368@TK2MSFTNGP02.phx.gbl...
> Fniles,
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/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" <fni***@pfmail.com> schreef in bericht
> news:uytVG0S0GHA.4044@TK2MSFTNGP04.phx.gbl...
>> 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.
>>
>>
>>
>
>
Author
6 Sep 2006 1:12 PM
Phill W.
fniles wrote:

> 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.