Old 10th March 2016, 21:13   #1
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
EnumRegkey Multiple values

Hi All,

I am trying to read a registry and get some values and store them on the fly . The below code works for finding and storing one matched key. How do I store the value of the key in a variable on the fly. This is what I have so far:


Var myFound
StrCpy $0 0
loop:
EnumRegKey $1 HKLM System\CurrentControlSet\services $0
StrCmp $1 "" done
${StrContains} $R1 "MySrch" "$1"
StrCmp $R1 "" notfound
StrCpy $myFound$1
MessageBox MB_OK 'Found string $1'
IntOp $0 $0 + 1
Goto loop
notfound:
IntOp $0 $0 + 1
goto loop
done:

As you can see the $myFound has the first match it finds in the registry. But there could be more than one "MySrch" keys in the registry. How Do I store the next occurance into a different variable?
pkonduru is offline   Reply With Quote
Old 10th March 2016, 23:05   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,195
Usually you would just do whatever you wanted to do with the key inside the loop before you continue searching but if you really need to store all of them in a list then you can write them to a .ini file or use the nsArray plugin.

If you are trying to enumerate services or drivers then you should call the correct Windows API and not enumerate the registry like this...
Anders is offline   Reply With Quote
Old 10th March 2016, 23:28   #3
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Thanks Anders for the reply.
I am trying to find windows services on a machine whose service name I don't know of except that there is a unique string in the service name. There could be multiple services with his name and I need to list these services in a listbox. The NSIS Simple service plugin doesn't let us pass a wild card. So this is what I have so far using the nsArray plugin. I need to figure out a way to make the "serv_array" global, so i can loop and add the list items dynamically on the custompage.

Var key
Var value
Var servFound

Function MyFunc
StrCpy $0 0
loop:
EnumRegKey $1 HKLM System\CurrentControlSet\services $0
StrCmp $1 "" done
${StrContains} $R1 "MyStr" "$1"
StrCmp $R1 "" notfound
;StrCpy $servFound $1
nsArray::Set serv_array $1
IntOp $0 $0 + 1
Goto loop
notfound:
IntOp $0 $0 + 1
goto loop
done:
${ForEachIn} serv_array $key $value

MessageBox MB_OK "my_array[$key] => $value"

${Next}

FunctionEnd
pkonduru is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast 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