Skip to content
⌘ NSIS Forum Archive

Registry substring search

1 posts

JoeMcC00L#edited

Registry substring search

Hello,

I'm using the Registry plugin to search for installed items in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. Here is the algorithm:

        ${registry::Open} "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" "/K=0 /V=0 /S=1 /B=1 /N='Apache HTTP Server 1.3.33'" $HANDLE
        ${registry::Find} "$HANDLE" $PATH $VALUE $STRING $TYPE
        ${If} $TYPE == ""
            MessageBox MB_OK "Status: Apache HTTP Server 1.3.33 was not found!"
        ${Else}
            MessageBox MB_OK "Status: Apache HTTP Server 1.3.33 was found! $\n \
                              $$PATH = $PATH $\n \
                              $$VALUE = $VALUE $\n \
                              $$STRING = $STRING $\n \
                              $$TYPE = $TYPE"
        ${EndIf}
        ${registry::Close} "$HANDLE" 
I would just use the key name, except in this case it's assigned to the GUID.

The algorithm works to find the Apache server, but I want to implement functionality to find any version of Apache. This is to determine if the software version that's installed is supported by my software. If not, I will prompt them to upgrade (which should be trivial). Is there a way to search for substrings in the registry, i.e., search for the string "Apache"?

Thanks,
Joe

EDIT:
:: Embarassed :: My apologies... as soon as I posted this I figured out a possible solution. Here's the algorithm:

        ${registry::Open} "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" "/K=0 /V=1 /S=0 /B=1 /N='DisplayName'" $HANDLE
        ${Do}
            ${registry::Find} "$HANDLE" $PATH $VALUE $STRING $TYPE
            StrCpy $R0 $STRING 6
            ${If} $R0 == "Apache"
                MessageBox MB_OK "Status: Apache is installed!"
                ${ExitDo}
            ${EndIf}
        ${LoopUntil} $TYPE == ""
        ${If} $TYPE == ""
             MessageBox MB_OK "Status: Apache is not installed!"
             call InstallApache
        ${Endif} 
This is kind of a pain, and it's not the most efficient algorithm. If any of you can think of something quicker, let me know.

Thanks again,
Joe