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?
EnumRegkey Multiple values
3 posts
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...
If you are trying to enumerate services or drivers then you should call the correct Windows API and not enumerate the registry like this...
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
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