Archive: Is WriteRegStr the same as WriteRegExpandStr?


Is WriteRegStr the same as WriteRegExpandStr?
  NSIS documentation for WriteRegStr says:

Write a string to the registry. See WriteRegExpandStr for more details.
NSIS documentation for WriteRegExpandStr says "Write a string to the registry" and it has the same exact syntax.

Are WriteRegStr and WriteRegExpandStr synonyms?

If not, what is the difference between the two?

Thanks,
Chris

the latter writes a string that gets expanded once it's read out through common windows APIs. NSIS doesn't do this automatically, but you can use ExpandEnvStrings after reading the string normally.


OutFile "test.exe"


>Section
MessageBox MB_OK "Writing out '%WINDIR%\notepad.exe'"
>WriteRegExpandStr HKLM "Software\Temp" "Temp" "%WINDIR%\notepad.exe"
>ReadRegStr $0 HKLM "Software\Temp" "Temp"
>MessageBox MB_OK "Read value: '$0'"
>ExpandEnvStrings $0 $0
MessageBox MB_OK "Expanded value: '$0'"
>DeleteRegKey HKLM "Software\Temp"
>SectionEnd
>
Above creates a registry key - delete when done

Originally posted by Animaether
[B]the latter writes a string that gets expanded once it's read out through common windows APIs. NSIS doesn't do this automatically, but you can use ExpandEnvStrings after reading the string normally.
Sorry for my ignorance but what does "expanded" mean?

Also, if WriteRegExpandStr is different from WriteRegStr, why doesn't the documentation say so?

Thanks,
Chris

check the code sample I wrote. Essentially it means that if an application reads the REG_EXPAND_SZ registry key using the proper APIs, instead of getting "%WINDIR%\notepad.exe", it will get the 'expanded' result of, for example, "c:\winxp\notepad.exe".

The %WINDIR% being a variable, if you will, that may differ depending on the exact windows installation, the current user logged in, etc.

The documentation probably doesn't mention they're different because it will only matter to those users who install an application that requires a REG_EXPAND_SZ string to be written out by the installer; presumably, you'd already know this requirement, look up how to write an expanded registry key, and then use the appropriate function from there :)


Thank you! It is clear now. The main thing I was missing was the reference to REG_EXPAND_SZ. You explained it so well. Thank you very much!