<doc>
  <legacy_id>1679</legacy_id>
  <name>setRegistry</name>
  <type>function</type>
  <syntax>
    <example>setRegistry(<i>keyPath</i>,<i>value</i>[,<i>type</i>])</example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>The System Environment</category>
  </classification>
  <references>
    <function tag="deleteRegistry">deleteRegistry Function</function>
    <function tag="MCISendString">MCISendString Function</function>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
    <changed version="2.0"></changed>
  </history>
  <platforms>
    <windows/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
  </classes>
  <security>
  </security>
  <summary>Sets an entry in the <glossary tag="registry">Windows system registry</glossary>.</summary>
  <examples>
    <example>setRegistry("HKEY_CLASSES_ROOT\.txt\", "NotePad")</example>
    <example>if setRegistry(myEntry &amp; "/",myValue) then open file myFile</example>
    <example>setRegistry(theKey,empty)</example>
  </examples>
  <description>
    <p>Use the <b>setRegistry</b> <control_st tag="function">function</control_st> to change the <glossary tag="behavior">behavior</glossary> of <function tag="openStacks">Windows</function>.</p><p/><p><b>Parameters:</b></p><p>The <i>keyPath</i> <glossary tag="parameter">parameter</glossary> is the <glossary tag="file path">path</glossary> to a <glossary tag="registry">registry</glossary> entry.</p><p/><p>The <i>value</i> is the new setting for the entry specified by the <i>keyPath</i>.</p><p/><p>The <i>type</i> is one of the following: "<code>binary</code>", "<code>dword</code>", "<code>dwordlittleendian</code>", "<code>dwordbigendian</code>", "<code>expandsz</code>", "<code>link</code>", "<code>multisz</code>", "<code>none</code>", "<code>resourcelist</code>", "<code>string</code>", or "<code>sz</code>". If you don't specify a <i>type</i>, "<code>string</code>" is used.</p><p/><p><b>Value:</b></p><p>The <b>setRegistry</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> true if the setting was successfully changed, false otherwise.</p><p/><p><b>Comments:</b></p><p>The first part of the <i>keyPath</i> should be one of the predefined handle values. If the <i>keyPath</i> ends in "\", the new setting becomes the <keyword tag="default">default</keyword> value. For example, if you want <function tag="files">files</function> ending in "<code>.rev</code>" to automatically launch LiveCode, use the following <glossary tag="command">command</glossary>:</p><p/><p><code/>  get setRegistry("HKEY_CLASSES_ROOT\.rev\", "LiveCode")</p><p/><p>If the key doesn't exist, the <b>setRegistry</b> <control_st tag="function">function</control_st> creates it in the <glossary tag="registry">registry</glossary>.</p><p/><p>To delete a subkey, set the subkey's <i>value</i> to empty.</p><p/><p>If the <i>type</i> is a <glossary tag="binary">binary</glossary> type, make sure the <i>value</i> is <glossary tag="binary">binary</glossary>. (You can encode a <keyword tag="string">string</keyword> as <glossary tag="binary data">binary data</glossary> using the <function tag="binaryEncode">binaryEncode</function> <control_st tag="function">function</control_st>.)</p><p/><p>If Windows sends an error message to the application, the <b>result</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> the <href tag="../dictionary/error_message.xml">error message</href>.</p><p/><p>On Mac OS and Unix systems, the <b>setRegistry</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> "not supported".</p><p/><p><code/><img src="202650"/> <b>Caution!</b><code/> Be careful to use only carefully debugged entries with the <b>setRegistry</b> <control_st tag="function">function</control_st>. Changing entries in the <glossary tag="registry">Windows registry</glossary> to invalid values can cause the system to behave unexpectedly or stop functioning altogether.</p><p/><p><b>Changes:</b></p><p>The <i>type</i> <glossary tag="parameter">parameter</glossary> was added in version 2.0. In previous versions, the type information could not be set.</p>
  </description>
</doc>