NAME
LinkTclVariableToRegistryValue — Make link to propagate changes from Tcl var to registry.
SYNOPSIS
LinkTclVariableToRegistryValue VarName RegistryKeyPath RegistryValueName
DESCRIPTION
Return Value
None.
Arguments
VarNameName of the variable to link.
RegistryKeyPathPath for registry key that the value is under.
RegistryValueNameName of the value to link.
More Info
This command creates a trace so that whenever the Tcl variable is updated, the registry value will be updated to match it.

Note that currently only global variables are supported.

If the Tcl variable does not already exist in the caller then one will be created and initialized to the empty string.

Note also that we do not yet have an option to cause the Tcl variable to receive the registry value data when the link is set up. Rather, the registry value will always be set to the value of the Tcl variable.

Note also that you must call UnlinkTclVariableFromRegistryValue in order to remove the trace. Currently there is nothing set up to automatically detect that the variable has gone out-of-existence and delete the trace.

Scalar variables only are supported. Nothing yet for linking arrays, lists, or dicts to the registry. We may add flags or other commands to support this in the future.

Finally, note that there is not currently a way to specify the type of registry value to create if one does not already exist. This command will always create a value of type REG_SZ. We may add an option in the future. If a registry value does already exist, then its type will be preserved.


For information regarding exceptions / errors, see here.
EXAMPLES
% registry set {HKEY_CURRENT_USER\Software\GenTest}
% registry set {HKEY_CURRENT_USER\Software\GenTest} testy 123
% puts [registry get {HKEY_CURRENT_USER\Software\GenTest} testy]
123
% set ::MyVar 345
% LinkTclVariableToRegistryValue ::MyVar {HKEY_CURRENT_USER\Software\GenTest} testy
% puts [registry get {HKEY_CURRENT_USER\Software\GenTest} testy]
345
% set ::MyVar 456
% puts [registry get {HKEY_CURRENT_USER\Software\GenTest} testy]
456
% UnlinkTclVariableFromRegistryValue ::MyVar {HKEY_CURRENT_USER\Software\GenTest} testy
% registry delete {HKEY_CURRENT_USER\Software\GenTest}
SEE ALSO
UnlinkTclVariableFromRegistryValue
KEYWORDS
link, registry, trace, variable