- NSIS Discussion
- Getting all sub-keys of a registry key
Archive: Getting all sub-keys of a registry key
cowwoc
30th June 2005 19:10 UTC
Getting all sub-keys of a registry key
I know how to read the value of a registry key, but how do I iterate through all it's children?
I've seen code floating around that will return the current installed JRE, but it does not return the build version. The only way to do that (so far as I can see) is to iterate all versions listed in the registry, finding the entry with the highest build number and returning that.
For example, instead of returning 1.5.0, I'm expecting the code to return 1.5.0_02
Gili
kichik
30th June 2005 19:17 UTC
Use EnumRegKey.
cowwoc
30th June 2005 21:14 UTC
Thank you. Now how does one strncmp()?
Specifically, I want to know whether the registry key returned has a name that starts with the string specified in $0.
kichik
30th June 2005 21:17 UTC
Copy only the number of characters you need using StrCpy's parameters (see documentation for more information and examples) and then use StrCmp or the LogicLib.
cowwoc
30th June 2005 21:27 UTC
I guess the same goes for dereferencing a specific character within a String? That is, I want to find the index of the first '_' within a String. Do I have to StrCpy one character at a time to find it?
kichik
30th June 2005 21:29 UTC
Yes, that's what you need to do. However, there are functions that already do that. StrStr is available in the documentation and others are available in the Wiki.
cowwoc
30th June 2005 21:38 UTC
I didn't know we had a Wiki. Look what I found: http://nsis.sourceforge.net/wiki/Get...uild/update%29
No need to write my own, someone else did it :) Thanks a lot!
Gili
Afrow UK
30th June 2005 21:43 UTC
I'll make rIndexOf and indexOf functions.
-Stu
cowwoc
30th June 2005 21:54 UTC
Excellent idea. It seems most scripts use them and end up reinventing the wheel. It would also clear up the code :)
deguix
1st July 2005 10:19 UTC
Ahnn... StrFunc already had a function called StrLoc where you can find the position of a string from the start or end of the main string, in one function. That means, you just reinvented the wheel.
I didn't like to post functions on Archive, but now, as the wiki is online, I can post the StrFunc functions there so they can be reselected for the future Useful Functions Header file.
Afrow UK
1st July 2005 11:45 UTC
Ah well never mind :D I was bored anyway lol
-Stu
deguix
1st July 2005 12:42 UTC
That's ok, 2 are better than 1 :D. Here goes the wiki link for StrLoc: http://nsis.sourceforge.net/wiki/StrLoc.