Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 30th June 2005, 18:10   #1
cowwoc
Member
 
Join Date: Feb 2005
Posts: 51
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
cowwoc is offline   Reply With Quote
Old 30th June 2005, 18:17   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Use EnumRegKey.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th June 2005, 20:14   #3
cowwoc
Member
 
Join Date: Feb 2005
Posts: 51
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.
cowwoc is offline   Reply With Quote
Old 30th June 2005, 20:17   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th June 2005, 20:27   #5
cowwoc
Member
 
Join Date: Feb 2005
Posts: 51
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?
cowwoc is offline   Reply With Quote
Old 30th June 2005, 20:29   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th June 2005, 20:38   #7
cowwoc
Member
 
Join Date: Feb 2005
Posts: 51
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
cowwoc is offline   Reply With Quote
Old 30th June 2005, 20:43   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
I'll make rIndexOf and indexOf functions.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th June 2005, 20:54   #9
cowwoc
Member
 
Join Date: Feb 2005
Posts: 51
Excellent idea. It seems most scripts use them and end up reinventing the wheel. It would also clear up the code
cowwoc is offline   Reply With Quote
Old 30th June 2005, 21:00   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Here you go:
http://nsis.sourceforge.net/wiki/Ind...cter_in_string

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 1st July 2005, 09:19   #11
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,351
Send a message via ICQ to deguix
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.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 1st July 2005, 10:45   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Ah well never mind I was bored anyway lol

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 1st July 2005, 11:42   #13
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,351
Send a message via ICQ to deguix
That's ok, 2 are better than 1 . Here goes the wiki link for StrLoc: http://nsis.sourceforge.net/wiki/StrLoc.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump