Archive: Reading Partial Registry String Values


Reading Partial Registry String Values
I know how to read complete strings and extract the values from them...but is there any way to just assign part of the value to a variable.

For Example:

the value of some reg key is "C:\anydir\anyfile.123"

can I read this value and set the variable to just "C:\anydir\" ???

Any help would greatly appreciated..Thanx



;------------------------------------------------------------------------------
; GetParent
; input, top of stack (i.e. C:\Program Files\Poop)
; output, top of stack (replaces, with i.e. C:\Program Files)
; modifies no other variables.
;
; Usage:
; Push "C:\Program Files\Directory\Whatever"
; Call GetParent
; Pop $0
; ; at this point $0 will equal "C:\Program Files\Directory"


Function GetParent
Exch $0 ; old $0 is on top of stack
Push $1
Push $2
StrCpy $1 -1
loop:
StrCpy $2 $0 1 $1
StrCmp $2 "" exit
StrCmp $2 "\" exit
IntOp $1 $1 - 1
Goto loop
exit:
StrCpy $0 $0 $1
Pop $2
Pop $1
Exch $0 ; put $0 on top of stack, restore $0 to original value
FunctionEnd

This was pulled out of the functions.htm file in your NSIS program dir.. this function might do what you are wanting.