setRegistry

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
setRegistry(<keyPath>, <value> [, <type>])
Summary

Sets an entry in the Windows system registry.

Introduced1.0
Changes

The type parameter was added in version 2.0. In previous versions, the type information could not be set.

OSwindows
Platformsdesktop, server
Parameters
NameTypeDescription
keyPath

The keyPath parameter is the path to a registry entry.

value

The new setting for the entry specified by the keyPath.

typebinary:
dword:
dwordlittleendian:
dwordbigendian:
expandsz:
link:
multisz:
none:
resourcelist:
string: (default)
sz:
Example
setRegistry("HKEY_CLASSES_ROOT\.txt\", "NotePad")
if setRegistry(myEntry & "/",myValue) then open file myFile
setRegistry(theKey,empty)
Values
NameTypeDescription
return

The setRegistry function returns true if the setting was successfully changed, false otherwise.

The result

If Windows sends an error message to the application, the result function returns the error message.

RelatedKeyword: default, string
Function: binaryEncode, deleteRegistry, MCISendString
Glossary: file, error message, return, Windows, binary file, registry, binary, command, behavior
Control Structure: function
Description

Use the setRegistry function to change the behavior of Windows.

The first part of the keyPath should be one of the predefined handle values. If the keyPath ends in "\", the new setting becomes the default value. For example, if you want files ending in ".rev" to automatically launch LiveCode, use the following command :

get setRegistry("HKEY_CLASSES_ROOT\.rev\", "LiveCode")

If the key doesn't exist, the setRegistry function creates it in the registry.

To delete a subkey, set the subkey's value to empty.

If the type is a binary type, make sure the value is binary. (You can encode a string as binary data using the binaryEncode function.)

On Mac OS and Unix systems, the setRegistry function returns "not supported".

Warning: Be careful to use only carefully debugged entries with the setRegistry function. Changing entries in the Windowsregistry to invalid values can cause the system to behave unexpectedly or stop functioning altogether.