Archive: Getting all sub-keys of a registry key


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


Use EnumRegKey.


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.


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.


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?


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.


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


I'll make rIndexOf and indexOf functions.

-Stu


Excellent idea. It seems most scripts use them and end up reinventing the wheel. It would also clear up the code :)


Here you go:
http://nsis.sourceforge.net/wiki/Ind...cter_in_string

-Stu


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.


Ah well never mind :D I was bored anyway lol

-Stu


That's ok, 2 are better than 1 :D. Here goes the wiki link for StrLoc: http://nsis.sourceforge.net/wiki/StrLoc.