Old 5th February 2006, 20:23   #1
lucian.crisan
Junior Member
 
Join Date: Feb 2006
Location: Cluj-Napoca, ROMANIA
Posts: 1
Send a message via Yahoo to lucian.crisan
Rebuild a registry key list

Hello guys,

I've wrote an instalation program (with NSIS Installer) for my application in AutoCAD.
Everything is OK at installation, but for uninstall function i need some help from you.
I'm a newbie with NSIS language, and i must finish asap my installation pack.
So, under a key i have a number of string values which follow the rule:

Value name: "index_number"Startup
Value data: a string which is the path to a specified file

For example:
1Startup "d:\Myapp\lisp1.lsp"
2Startup "d:\Myapp\lisp2.lsp"
3Startup "d:\Myapp\lisp3.lsp"
4Startup "d:\Myapp\lisp4.lsp"
5Startup "d:\Myapp\lisp5.lsp"
6Startup "d:\Myapp\lisp6.lsp"
NumStartup "6"

At the end exist a key, named "NumStartup" and its value is equal with a number which reppresent the number of files "loaded" under this key (like an index)

In the time of uninstall, i want to erase for example the fourth key (4Startup "d:\Myapp\lisp4.lsp") and to change value of NumStartup from 6 to 5.
This part i've done, but i need to rebuild the key's value name in ascending order.

The situation appear like follow (after erase of the fourth key):

1Startup "d:\Myapp\lisp1.lsp"
2Startup "d:\Myapp\lisp2.lsp"
3Startup "d:\Myapp\lisp3.lsp"
5Startup "d:\Myapp\lisp5.lsp"
6Startup "d:\Myapp\lisp6.lsp"
NumStartup "5"

What i'll need to obtain:

1Startup "d:\Myapp\lisp1.lsp"
2Startup "d:\Myapp\lisp2.lsp"
3Startup "d:\Myapp\lisp3.lsp"
4Startup "d:\Myapp\lisp5.lsp"
5Startup "d:\Myapp\lisp6.lsp"
NumStartup "5"

This job, at this moment, i can't handle it; and i'm asking you if anyone can help me (or guide me) to finish up my job.

And another question. I have a key which contain some paths linked with ";" character, like:
C:\ACADM2000\acadm;C:\ACADM2000\help;C:\ACADM2000\FONTS;D:\My work;
How can I search for a specified path inside this string, erase it, and rebuild the string without it.

I don't know if i was explicit by I try with an example.

I have this key:
Value name: ACAD
Value data: "C:\ACADM2000\acadm;C:\ACADM2000\help;C:\ACADM2000\FONTS;D:\My work;"

I want to search and erase the substring "C:\ACADM2000\help;C:\ACADM2000\FONTS;" from initial string to obtain
C:\ACADM2000\acadm;D:\My work;

That's all.
Thanks in forward,
Lucian
lucian.crisan is offline   Reply With Quote
Old 5th February 2006, 21:52   #2
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
Hmm... let's see...

This code should fix the list order.
code:
Push $R0
Push $R1
Push $R2

; Change this to ReadRegDWORD if necessary
ReadRegStr $R0 HKCU "Software\Something" "NumStartup"

StrCpy $R1 0 ; "fix pointer"
StrCpy $R2 0 ; pointer

loop:
StrCmp $R2 $R0 end 0
IntOp $R1 $R1 + 1

notfound:
ClearErrors ; just to make sure
IntOp $R2 $R2 + 1
StrCmp $R2 $R0 end 0

ReadRegStr $R3 HKCU "Software\Something" "$R2Startup"
IfErrors notfound 0
DeleteRegValue HKCU "Software\Something" "$R2Startup"
WriteRegStr HKCU "Software\Something" "$R1Startup" $R3
Goto loop

end:
IntOp $R1 $R1 - 1
WriteRegStr HKCU "Software\Something" "NumStartup" $R1

Pop $R2
Pop $R1
Pop $R0


Probably There are easier way to do this, but my brain needs food.
{_trueparuex^} is offline   Reply With Quote
Old 5th February 2006, 23:40   #3
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
You might want to check out AfrowUK's NSISArray plugin--it would make it easier to switch the order of elements and such without having to make your brain hurt so much!

and for this:
Quote:
C:\ACADM2000\acadm;C:\ACADM2000\help;C:\ACADM2000\FONTS;D:\My work;
How can I search for a specified path inside this string, erase it, and rebuild the string without it.
You should have a look at Instructor's Word/String/File functions. (BTW: Most of Instructor's functions are included with the latest builds of NSIS--have a look at the help files for for info.)
Comperio 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