Skip to content
⌘ NSIS Forum Archive

Registry plugin

229 posts

Instructor#
Like this?
Section /o "Search and write founded in text file" SearchAndWriteInFile
StrCpy $R0 HKEY_CURRENT_CONFIG

${registry::Open} "$R0" "/K=0 /B=1" $0
StrCmp $0 -1 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} $1 $2 $3 $4

StrCmp $4 '' close
WriteINIStr 'C:\filename.ini' '$R0\$1\$2' '$2' '$3'
goto loop

close:
${registry::Close}
${registry::Unload}
FileClose $R1

Exec '"notepad.exe" "C:\filename.ini"'
SectionEnd
rxs2k5#
nice nice thanks
but how do I extent the search beside this
HKEY_CURRENT_CONFIG

like

HKEY_LOCAL_MACHINE " name of software " "the value" "data"
HKEY CURRENT USERS " Name of software " " the value" "data"
Section /o "Search and write founded in text file" SearchAndWriteInFile
StrCpy $R0 HKEY_CURRENT_CONFIG

${registry::Open} "$R0" "/K=0 /B=1" $0
StrCmp $0 -1 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} $1 $2 $3 $4

StrCmp $4 '' close
WriteINIStr 'C:\filename.ini' '$R0\$1\$2' '$2' '$3'
goto loop

close:
${registry::Close}
${registry::Unload}
FileClose $R1

Exec '"notepad.exe" "C:\filename.ini"'
SectionEnd
Instructor#
but how do I extent the search beside this
HKEY_CURRENT_CONFIG

like

HKEY_LOCAL_MACHINE " name of software " "the value" "data"
HKEY CURRENT USERS " Name of software " " the value" "data"
Don't understand. What your situation (what you trying to do)?
rxs2k5#
Section /o "Search and write founded in text file" SearchAndWriteInFile
StrCpy $R0 HKEY_CURRENT_User
StrCpy $R1 HKEY_Local_ Machine

${registry::Open} "$R0" "/K=0 /B=1" $0
StrCmp $0 -1 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} $1 $2 $3 $4

StrCmp $4 '' close
WriteINIStr 'C:\filename.ini' '$R0\$1\$2' '$2' '$3'
goto loop

close:
${registry::Close}
${registry::Unload}
FileClose $R1

Exec '"notepad.exe" "C:\filename.ini"'
SectionEnd
1.
If u look at the example above the HKEY_CURRENT_User which will be written into the filename.ini takes a long time to search since it will scan the entire registry on HKEY_CURRENT_User is there anyway to define it to search the material much faster and direct.

2. HKEY_CURRENT_User "Software\blah" "search string value" " string value data " is this possible to direct a search rather than a full scan of the HKEY_CURRENT_User.

3. this will be read by ReadINIStr afterwards when the search is being done since ReadINIStr requires section_name entry_name. Is there a possibility that your registry plugin can arrange this to fit into the search in ReadINIStr like this
ReadINIStr $0 $Temp\filename.ini example1 cool on the later part.


thanks again for replying
Instructor#
is this possible to direct a search rather than a full scan of the HKEY_CURRENT_User
Direct search for what? For key "blah"?
Instructor#
ok. I need to understand what you trying to do.
1. You know that registry key name is "blah"
2. You know that this key located somewhere in the "HKEY_CURRENT_USER\Software" (it can be "HKEY_CURRENT_USER\Software\123\blah" or "HKEY_CURRENT_USER\Software\Microsoft\blah" ...)
3. You need to find all this variants and write them to the ini file
Is this correct?
Instructor#
Section /o "Search and write founded in text file" SearchAndWriteInFile
StrCpy $R0 "HKEY_CURRENT_USER" #Root
StrCpy $R1 "Software" #Subkey "Key1\Ke2\Key3"
StrCpy $R2 0

${registry::Open} "$R0\$R1" "/K=1 V=0 /S=0 /N='blah' /B=1" $0
StrCmp $0 -1 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} $1 $2 $3 $4

StrCmp $4 '' close
WriteINIStr 'C:\filename.ini' 'Example1' '$R2' '$R0\$1\$2'
IntOp $R2 $R2 + 1
goto loop

close:
${registry::Close}
${registry::Unload}

Exec '"notepad.exe" "C:\filename.ini"'
SectionEnd
Instructor#
Added:    registry::SaveKey option /A=[0|1], /A=1 append data to the file
Changed: registry::RestoreKey some clean-up


"Registry" plugin v2.5
Instructor#
Fast fix: registry::Open does not reset variables (more then one call)


"Registry" plugin v2.6
Deuce199#
Search Loop

I am using a search function in my registry program using your plugin. I am now using your append switch of savekey to append the found keys to a reg file and it works like a charm. This is my problem:

Say I search for Key1 in HKEY_Local_MAchine, so it find key1 and writes it to the reg file, i then have it loop back and search again. The problem is it will refind the first instance of key1 and keep going, never getting past that key, because it does not remember it did that. How or can you add function that will cause the search to continue from the point it stopped to write the information to a file. So it would continue from the first instance of key1 and go to the next instance? Is that possible?

Thanks,
Deuce199
Instructor#
With v2.7:
Name "Output"
OutFile "Output.exe"

!include "Registry.nsh"

Section
StrCpy $R0 "HKEY_LOCAL_MACHINE" #Root
StrCpy $R1 "SOFTWARE\Microsoft" #Subkey

${registry::Open} "$R0\$R1" "/K=1 V=0 /S=0 /N='Key1' /B=1" $0
StrCmp $0 -1 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} $1 $2 $3 $4

StrCmp $4 '' close
${registry::SaveKey} "$R0\$1\$2" "C:\keys.reg" "/A=1 /B=1" $0
goto loop

close:
${registry::Close}
${registry::Unload}

Exec '"notepad.exe" C:\keys.reg'
SectionEnd
Instructor#
Fixed: separate registry::Find and registry::SaveKey stacks. Now possible use them
          together.


"Registry" plugin v2.7
Instructor#
Updated: "StackFunc.h" to v1.8
Added: handles for search


"Registry" plugin v2.8
Red Wine#
Cool! Awesome plugin, and getting even better,
thanks Instructor.
BTW a more detailed documentation would be great :-)
Instructor#
Updated: "StrFunc.h" to v1.7
Updated: "StackFunc.h" to v1.9
Updated: "ConvFunc.h" to v1.7


"Registry" plugin v2.9
Instructor#
Added: registry::Open options
            "/NS=[name]" - sensitive search for a part of name
            "/NI=[name]" - insensitive search for a part of name


"Registry" plugin v3.0
Deuce199#
Multiple key Regsearch

Instructor,

First thanks for the help, I am sorry it took so long to get back to you.

Second, I am having the same problem, What I need is for my search algorithm to search the registry for a specific keyword. If found save the key to a reg file, then from that point, the regkey it just wrote, continue to search the rest of the registry for that keyword. If another is found then save, start from that point and continue, and so on until it hits the end of the registry.

Here is my search function:


!define RegSearch `!insertmacro RegSearch`

!macro RegSearch rootKey searchWord

${registry::Open} "${rootKey}" "/K=1 /V=0 /S=0 /B=0 /N='${searchWord}'" $0
StrCmp $0 0 0 +2
MessageBox MB_OK "Error" IDOK +9
${registry::Find} "$0" $1 $2 $3 $4
StrCmp $4 '' +7
StrCmp $4 'REG_KEY' 0 +4
StrCpy $REGKEY "${rootKey}\$1\$2\$3"
${Registry::SaveKey} "$REGKEY" "${SETDIR}\Settings.reg" "/A=1 /G=1" $R0
StrCpy $RC "1"
goto -7

${registry::Close} "$0"
${registry::Unload}
!macroend
After the 'StrCpy $RC "1"' line it should jump back to the registry::find line and continue to search the registry for the next key.

What it is doing it going back to the beginning of the opened root key and starting again, So it hits the already saved key and appends it to the regfile.

Basically it creates a loop that creates a file that will keep writing the same info over and over again, until I kill it in the task manager.

Is it possible for me to do this with your plugin? If so, how should I change the code above to make it work?

thanks for all your help with this.

Deuce
Deuce199#
How would I go about coding something like that?

Right now, That is my macro. I call that macro from within my main prog script. It is my regsearch function pretty much.
Instructor#
Something like this:
Function RegSearch
!define RegSearch `!insertmacro RegSearchCall`

!macro RegSearchCall rootKey searchWord
Push `${rootKey}`
Push `${searchWord}`
Call RegSearch
!macroend

Exch $R1
Exch
Exch $R0
Exch
Push $0
Push $1
Push $2
Push $3
Push $4
Push $5

${registry::Open} "$R0" "/K=1 /V=0 /S=0 /B=0 /N='$R1'" $0
StrCmp $0 0 0 +2
MessageBox MB_OK "Error" IDOK end

find:
${registry::Find} "$0" $1 $2 $3 $4
StrCmp $4 '' end
StrCpy $REGKEY "$R0\$1\$2\$3"
${registry::SaveKey} "$REGKEY" "${SETDIR}\Settings.reg" "/A=1 /G=1" $5
StrCpy $RC "1"
goto find

end:
${registry::Close} "$0"
${registry::Unload}

Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
Pop $R1
Pop $R0
FunctionEnd
Deuce199#
Registry.dll left in Temp

I noticed while using your plugin in some of my code, that after the registry plugin is copied to the temp directory, it still is there even after the program is shutdown.

My point is, after running the program ten times say, I have ten temp folders all containing the registry.dll file. They add up after a time.

Is this something that can be fixed?

Thanks, Deuce.

PS. thanks for the help on the above function, I am still trying to find the time to try it out.
bholliger#
Hi Deuce199!

It seems that you don't execute the 'unload'-function by the time you've finished using the plugin.

Have a look at the excellent readme.txt for further information.


; **** Unload plugin ****

${registry::Unload}
Cheers

Bruno
makutaku#
Unable to use plug-in, please help !

Both Registry.dll and PPC-Registry.dll were copied to NSIS plugin directory, but when I try to use them in my nsi file I get compilation errors:

When I call either Registry::Open or PC-Registry::CeRapiInit
both generate an invalid command error.

I am able to use other plugins, such as nsislog.dll, so I don't undesrtand what's different with Registry.dll and PPC-Registry.dll. Does anybody know what I am missing ? Do I need to include anything in my nsi code to use these plugins?
Comperio#
You have to:[list=1][*]Get the DLLs moved to the plugins folder (which sounds like you have)[*]Move REGISTRY.NSH to the include folder[*]Add !Include 'REGISTRY.NSH' to the top of your script.[*]Make your calls using the built-in defines rather than regular plugin calls. (Example: Use ${registry::Open}, not Registry::Open)[/list=1]
See the README.TXT file included with the plugin along with the included sample script. 😎