1
votes

During install I want to write a long multi line/paragraph chunk of text to a registry value

writing to a registry value is easy enough

[Registry] Root: HKCU; Subkey: "Software\my company\My software"; ValueType: string; ValueName: "Message"; ValueData: "some text"

but I would rather define a multi line text constant to replace "some text"

i.e. something like

mytext = "some long text value\r\ngoning onto another line"

Root: HKCU; Subkey: "Software\my company\My software"; ValueType: string; ValueName: "Message"; ValueData: #mytext

I am probably being dull but I can't see how to do this - any help gratefully appreciated. Thanks

1

1 Answers

2
votes

Using a simple variable should work.

#define mytext "some long text value\r\ngoing onto another line" 

[Registry] Root: HKCU; Subkey: "Software\my company\My software"; ValueType: string; ValueName: "Message"; ValueData: "{#mytext}"

However, writing a ValueType: string to a registry in Windows means you are writing a REG_SZ. The \r\n will appear as text in the registry value. Most registry tools do not support carriage return in REG_SZ value. They will simply display the characters.

You will have to handle it yourself in the program that uses that registry value. Some examples here.

A better solution if it fits your requirements is to tell inno to use a REG_MULTI_SZ with the ValueType: multisz. REG_MULTI_SZ is a sequence of null-terminated strings terminated by an empty string (\0). With inno multisz's type value, you may use a special constant called {break} to embed line breaks. Consult the documentation for the usage.