Meaning of the tilde in registry values for compatibility mode in Windows 8+

I've to support a legacy application, originally created for Windows NT 4 (32-bit), but still running fine under Windows 10 (64-bit), provided all of the compatibility settings are done. The problem is that these have to be done mostly by hand.

I'm trying to figure out how to build a program or script that I could deliver for that purpose. I already know that the compatibility settings are stored in the registry under HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers or HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers respectively (depending whether the settings are applied to all or just a single user), by adding values whose names are the application paths like for instance

C:\Program Files (x86)\SomeApp\SomeBinary.exe 

adding contents like (for enabling compatibility to Windows XP Service Pack 3)

WINXPSP3

as observed on Windows 7, or

~ WINXPSP3

as observed on Windows 8.1 (and Windows 8)

What I want to understand before shipping such a tool is:

What is the purpose or meaning of the tilde sign starting the value contents?

I'm searching for it for months (Google, Bing) but by now, I found nothing but questions. There's only a guess that it as well could be meaningless(?):

When compatibility mode is set via Properties, Windoze places a tilde (~) followed by a space before the value, e.g. "~ WINXPSP3". Yet it seems to work (or not work as the case may be) regardless of the tilde.

But most suggestions about adjusting compatibility settings seem to take much care of this magic char:

Note that there is a space between the tilde and the HIGHDPIAWARE.

Is there anybody who really knows something about it?


I was looking into this same thing and found this (emphasis mine):

If the value contains the sequence tilde [~], then the value is interpreted as a Null-delimited list of strings (REG_MULTI_SZ). For example, to specify a list containing the three strings a, b and c, use "a[~]b[~]c".

The sequence [~] within the value separates the individual strings and is interpreted and stored as a Null character.

If a [~] precedes the string list, the strings are to be appended to any existing registry value strings. If an appending string already occurs in the registry value, the original occurrence of the string is removed.

If a [~] follows the end of the string list, the strings are to be prepended to any existing registry value strings. If a prepending string already occurs in the registry value, the original occurrence of the string is removed.

If a [~] is at both the beginning and the end or at neither the beginning nor the end of the string list, the strings are to replace any existing registry value strings.

Otherwise, the value is interpreted and stored as a string (REG_SZ).

Source: the article Registry Table (Windows) in the Installer Database Reference

So it appears that the tilde character just appends or prepends string values.