/AutoHotkey.docset/Contents/Resources/Documents/commands/SetRegView.htm

https://gitlab.com/ahkscript/Autohotkey.docset · HTML · 68 lines · 54 code · 14 blank · 0 comment · 0 complexity · 893a0174670e1a52e7817792660e18b1 MD5 · raw file

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>SetRegView</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  8. <script src="../static/content.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <h1>SetRegView <span class="ver">[v1.1.08+]</span></h1>
  12. <p>Sets the registry view used by RegRead, RegWrite, RegDelete and registry loops.</p>
  13. <pre class="Syntax">SetRegView, RegView</pre>
  14. <h3>Parameters</h3>
  15. <dl>
  16. <dt>RegView</dt>
  17. <dd>
  18. <p>Specify <strong>32</strong> to view the registry as a 32-bit application would, or <strong>64</strong> to view the registry as a 64-bit application would.</p>
  19. <p>Specify the word <strong>Default</strong> to restore normal behaviour.</p>
  20. </dd>
  21. </dl>
  22. <h3>General Remarks</h3>
  23. <p>This command is only useful on Windows 64-bit. It has no effect on Windows 32-bit.</p>
  24. <p>On 64-bit systems, 32-bit applications run on a subsystem of Windows called <a href="http://msdn.microsoft.com/en-us/library/aa384249">WOW64</a>. By default, the system redirects certain <a href="http://msdn.microsoft.com/en-us/library/aa384253">registry keys</a> to prevent conflicts. For example, in a 32-bit script, <code>HKLM\SOFTWARE\AutoHotkey</code> is redirected to <code>HKLM\SOFTWARE\Wow6432Node\AutoHotkey</code>. SetRegView allows the registry commands in a 32-bit script to access redirected keys in the 64-bit registry view and vice versa.</p>
  25. <p>The built-in variable <em>A_RegView</em> contains the current setting. Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
  26. <h3>Related</h3>
  27. <p><a href="RegRead.htm">RegRead</a>, <a href="RegWrite.htm">RegWrite</a>, <a href="RegDelete.htm">RegDelete</a>, <a href="LoopReg.htm">Loop (registry)</a></p>
  28. <h3>Examples</h3>
  29. <p id="example1">Example 1 shows how to set a specific registry view, and how registry redirection affects the script.</p>
  30. <pre><em>; Access the registry as a 32-bit application would.</em>
  31. SetRegView 32
  32. RegWrite REG_SZ, HKLM, SOFTWARE\Test.ahk, Value, 123
  33. <em>; Access the registry as a 64-bit application would.</em>
  34. SetRegView 64
  35. RegRead value, HKLM, SOFTWARE\Wow6432Node\Test.ahk, Value
  36. RegDelete HKLM, SOFTWARE\Wow6432Node\Test.ahk
  37. MsgBox Read value '%value%' via Wow6432Node.
  38. <em>; Restore the registry view to the default, which
  39. ; depends on whether the script is 32-bit or 64-bit.</em>
  40. SetRegView Default
  41. <em>;...</em>
  42. </pre>
  43. <p id="example2">Example 2 shows how to detect the type of EXE and operating system on which the script is running.</p>
  44. <pre>if (A_PtrSize = 8)
  45. script_is := "64-bit"
  46. else <em>; if (A_PtrSize = 4)</em>
  47. script_is := "32-bit"
  48. if (A_Is64bitOS)
  49. OS_is := "64-bit"
  50. else
  51. OS_is := "32-bit, which has only a single registry view"
  52. MsgBox This script is %script_is%, and the OS is %OS_is%.</pre>
  53. </body>
  54. </html>