Skip to content
⌘ NSIS Forum Archive

Read Registry keys into listbox

6 posts

jmaerten#

Read Registry keys into listbox

I have several registry keys within one registry key, and I would like these keys to be put into a listbox that is used in the installation. For example I would have:
HKLM SOFTWARE\MySoftware\cat
HKLM SOFTWARE\MySoftware\dog
HKLM SOFTWARE\MySoftware\rooster
HKLM SOFTWARE\MySoftware\elephant

So, in my listbox I would want the items: cat, dog, rooster, and elephant. This is because these keys have unique directory values that choose where the install directory should be.

Please note: I would like this without using the registry plugin if possible. I don't know if ReadRegStr can read keys instead of just values.

Thanks for your help!
dienjd#
Have you tried EnumRegKey?
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2 (4.9.2.5). Seems like you can use this to enumerate your subkeys and then parse off everything before the final "\" to get the subkey name itself.
jmaerten#
Using that function worked, thanks for your help.

But, I still need help figuring out which item was selected. I am looking at the ListBox example, but I can't figure it out yet. In my ini file, the "Field 2" is the listbox. I want to disable the next button until an item is selected. Once it is selected, I want to be able to use it (ie. stored in a global variable) If anyone can tell me the code to do this I'd greatly appreciate it.
Afrow UK#
If you want to keep it simple you can try my PopupListBox plugin at http://nsis.sf.net/File:PopupListBox.zip
I'm also releasing an EmbeddedListBox plugin which is like an IO page except you can have a multicolumn list view with headings (report view) and optionally with checkboxes as well.

-Stu
RobGrant#
It might be easier to keep the next button enabled, but just abort the leave function if they haven't selected anything.

To find out what they've selected, just use:

Push $0
!insertmacro MUI_INSTALLOPTIONS_READ $0 "ininame.ini" "Field 1" "State"
Where your ini is called ininame.ini, and your list is in Field 1.