Skip to content
⌘ NSIS Forum Archive

Workaround for impractical WriteRegMultiStr syntax

4 posts

Lee Powell#

Workaround for impractical WriteRegMultiStr syntax

Found a MakeNSISW-compatible syntax example for WriteRegMultiStr in this closed support ticket:



AFAICT, all other Nullsoft sources of documentation of WriteRegMultiStr specify syntax that generates compile errors in MakeNSISW.

The idiosyncratic hex format required by WriteRegMultiStr works when specified as a literal text parameter or in a compile-time !define string. What DOES NOT WORK is passing the required hex string in any type of string variable. This means that in order to use WriteRegMultiStr in an NSI script, you must not only type the literal text explicitly into the source code, you have to hand-encode it in this unreadable hex format. That makes it impossible to pass the text to the script as either a command line parameter or in a text file.

Is there any practical workaround available in NSIS to write programmable text fields into multi-string Registry keys?
Anders#
https://nsis.sourceforge.io/Registry_plug-in or https://stackoverflow.com/a/41388709...values-in-nsis

REG_MULTI_SZ is really a set of strings separated by \0 characters and NSIS scripts do not currently support dealing with those in any sort of fashion.
Lee Powell#
Thanks for the reply, but compile-time macro manipulation of the hex string specified to WriteRegMultiStr doesn't address my question. My problem is that WriteRegMultiStr requires a hex string specified as a literal string declared at compile-time. What I need is a workaround that will enable me to write text strings specified at install-time into REG_MULTI_SZ registry fields.

Also, the hex format required by WriteRegMultiStr does not contain any \0 characters, only ASCII-encoded hex digits. Why does WriteRegMultiStr accept a literal string of hex digits, but rejects a string variable that contains that string of hex digits?
Anders#
I linked to two different workarounds that can be used at run time. Everything else is pointless to talk about because I know you want to do WriteRegMultiStr HKCU "Foo\Bar" "Baz" $MyData but NSIS does not support that at this time.

The hex format currently required by WriteRegMultiStr does contain \0 because \0 is 00 in hex. \0 is also used to terminate normal strings in variables which is why this is hard. You can either sacrifice some other character and use that as the separator (The Registry plug-in does that) or you can build the multi-str in parts and the other link does that.

The compiler supports a literal string of hex codes because the compiler transforms those to bytes and the installer just writes those bytes directly into the registry.