Archive: Can't abstract all variables in Registry Edit/Delete Call...HKLM must be clear text?


Can't abstract all variables in Registry Edit/Delete Call...HKLM must be clear text?
[ Preface, I realize that I now have three distinct discussions on abstracting variables out of compile time and into runtime.... I'll stop posting threads now until I get them resolved, but they ARE all different issues....]

Evidentially I am pushing the boundaries of the programming language a bit here in desiring a greater abstraction than exists..... but why does an enumerated string ( HKLM/HKCU etc ) not get resolved at runtime if the remaining parameters that are getting passed to it can be? Seems to be an oversight in the kernal's handling of those parameters.... should just have a case statement resolve the variable... just like it does for the keys...

This is a limitation that makes the alter registry calls much less flexible....


; $R1 is set to "HKLM"
; $R2 is set to "SomeRegistryKey\SomeCustomProgram"
; $R3 is set to "SomeEntryName"
; $R4 is set to "13523" ( a value )

# THIS PASSES COMPILE
DeleteRegValue HKLM $R2 $R3

# THIS DOES NOT
DeleteRegValue $R1 $R2 $R3

#SAME WITH THIS:
WriteRegStr HKLM $R2 $R3 $R4
# VERSUS THIS:
WriteRegStr $R1 $R2 $R3 $R4


So it becomes impossible to keep a pure log entry of the registry items that were edited. You'd have to group them by HKLM etc... or $SWITCH handle the parameter when you called the DeleteRegValue, WriteRegStr, ReadRegStr etc...

$Switch $R1
$Case "HKLM"
DeleteRegValue HKLM $R2 $R3
$Case "HKCU"
DeleteRegValue HKCU $R2 $R3
$Case "HKCU"
DeleteRegValue HKCC $R2 $R3

....Etc. Etc. Etc.

I feel like I'm at the point where I need to start pushing on the ceiling a bit. How do I learn to change/edit expand the part of the programming that controls these functions? Or is the base NSIS kernal only edited by submission and conseses?

_Thanks...[ going silent now till I get some answers.]


It is so that the hkey can be verified at compiletime (I don't agree with this design, but it is the way it works ATM) you can use the registry plugin as a workaround


Example of the curren workaround.....
Example of the handling I need to do to get my abstraction to compile. It seems unnecessary.... but if I understood why the compiler required the Enumeration I probably would understand the languages limitations a bit better. This compiled:

[CODE; Because GetBetween only uses files as sources.... ( stupid, that I'm using that here, but I am.... )
${GetBetween} "<NEW>" "</NEW>" "$1\SRS_TempFile.txt" $4 ; Get the file name between the file tags of the read_line_in->$2 and stick it in $4
${GetBetween} "<ROOT>" "</ROOT>" "$R1\SRS_TempFile.txt" $R1 ; Get the file name between the file tags of the read_line_in->$2 and stick it in $R2
${GetBetween} "<KEY>" "</KEY>" "$1\SRS_TempFile.txt" $R2 ; Get the file name between the file tags of the read_line_in->$2 and stick it in $4
${GetBetween} "<SUBKEY>" "</SUBKEY>" "$1\SRS_TempFile.txt" $R3 ; Get the file name between the file tags of the read_line_in->$2 and stick it in $R3
${GetBetween} "<VALUE>" "</VALUE>" "$1\SRS_TempFile.txt" $R4 ; Get the file name between the file tags of the read_line_in->$2 and stick it in $R4


StrCmp $4 "1" 0 SRS_RESTORE_WRITE ; if the new marker is set to 1 then a rollback means remove it entirely.....
${Switch} $R1
${Case} "HKLM"
DeleteRegValue HKLM $R2 $R3
${Case} "HKCR"
DeleteRegValue HKCR $R2 $R3
${Case} "HKCU"
DeleteRegValue HKCU $R2 $R3
${Case} "HKU"
DeleteRegValue HKU $R2 $R3
${Case} "HKCC"
DeleteRegValue HKCC $R2 $R3
${Case} "HKDD"
DeleteRegValue HKDD $R2 $R3
${Case} "HKPD"
DeleteRegValue HKPD $R2 $R3
${Case} "SHCTX"
DeleteRegValue SHCTX $R2 $R3
${EndSwitch}
Goto SRS_RESTORE_ReadLine[/CODE]


But THIS works?
!macro SetRegistry_with_RollbackControl _RootKey _RegistryKey _SubKey _Value

WriteRegStr ${_RootKey} ${_RegistryKey} ${_SubKey} ${_Value}

!macroend


The root key cannot be a variable.

Stu


But it can be SHCTX.


Grrrrrr.
It IS a variable. Its just an enumerated, restricted pre-defined set of acceptable values and it should beable to say, OH... variable... that resolves to... and if it can't resolve at runtime it throws an error the same as if the KEY didn't exist.....

The system compiler call SHOULD take runtime resolution of that variable, just like it can for the REST of the variables.

If this annoyed me enough.... What do I need to read to learn how I go about changing it?... more as an exercise of becoming a god-like NSIS designer....than anything else. A few cumbersome casestatements aren't really worth it... but just SAY I wanted to......

_Andrew