~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/stdlib/doc/src/win32reg.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>2000</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>win32reg</title>
 
27
    <prepared>Bjorn Gustavsson</prepared>
 
28
    <responsible>NN</responsible>
 
29
    <docno></docno>
 
30
    <approved>nobody</approved>
 
31
    <checked>no</checked>
 
32
    <date>2000-08-10</date>
 
33
    <rev>PA1</rev>
 
34
    <file>win32reg.sgml</file>
 
35
  </header>
 
36
  <module>win32reg</module>
 
37
  <modulesummary>win32reg provides access to the registry on Windows</modulesummary>
 
38
  <description>
 
39
    <p><c>win32reg</c> provides read and write access to the
 
40
      registry on Windows. It is essentially a port driver wrapped around the
 
41
      Win32 API calls for accessing the registry.</p>
 
42
    <p>The registry is a hierarchical database, used to store various system
 
43
      and software information in Windows. It is available in Windows 95 and
 
44
      Windows NT. It contains installation data, and is updated by installers
 
45
      and system programs. The Erlang installer updates the registry by adding
 
46
      data that Erlang needs.</p>
 
47
    <p>The registry contains keys and values. Keys are like the directories
 
48
      in a file system, they form a hierarchy. Values are like files, they have
 
49
      a name and a value, and also a type.</p>
 
50
    <p>Paths to keys are left to right, with sub-keys to the right and backslash
 
51
      between keys. (Remember that backslashes must be doubled in Erlang strings.)
 
52
      Case is preserved but not significant.
 
53
      Example: <c>"\\\\hkey_local_machine\\\\software\\\\Ericsson\\\\Erlang\\\\5.0"</c> is the key
 
54
      for the installation data for the latest Erlang release.</p>
 
55
    <p>There are six entry points in the Windows registry, top level keys. They can be
 
56
      abbreviated in the <c>win32reg</c> module as:</p>
 
57
    <pre>
 
58
Abbrev.          Registry key
 
59
=======          ============      
 
60
hkcr             HKEY_CLASSES_ROOT
 
61
current_user     HKEY_CURRENT_USER
 
62
hkcu             HKEY_CURRENT_USER
 
63
local_machine    HKEY_LOCAL_MACHINE
 
64
hklm             HKEY_LOCAL_MACHINE
 
65
users            HKEY_USERS
 
66
hku              HKEY_USERS
 
67
current_config   HKEY_CURRENT_CONFIG
 
68
hkcc             HKEY_CURRENT_CONFIG
 
69
dyn_data         HKEY_DYN_DATA
 
70
hkdd             HKEY_DYN_DATA</pre>
 
71
    <p>The key above could be written as <c>"\\\\hklm\\\\software\\\\ericsson\\\\erlang\\\\5.0"</c>.</p>
 
72
    <p>The <c>win32reg</c> module uses a current key. It works much like the
 
73
      current directory. From the current key, values can be fetched, sub-keys
 
74
      can be listed, and so on.</p>
 
75
    <p>Under a key, any number of named values can be stored. They have name, and
 
76
      types, and data.</p>
 
77
    <p>Currently, the <c>win32reg</c> module supports storing only the following
 
78
      types: REG_DWORD, which is an
 
79
      integer, REG_SZ which is a string and REG_BINARY which is a binary.
 
80
      Other types can be read, and will be returned as binaries.</p>
 
81
    <p>There is also a "default" value, which has the empty string as name. It is read and
 
82
      written with the atom <c>default</c> instead of the name.</p>
 
83
    <p>Some registry values are stored as strings with references to environment variables,
 
84
      e.g. <c>"%SystemRoot%Windows"</c>. <c>SystemRoot</c> is an environment variable, and should be
 
85
      replaced with its value. A function <c>expand/1</c> is provided, so that environment
 
86
      variables surrounded in % can be expanded to their values.</p>
 
87
    <p>For additional information on the Windows registry consult the Win32
 
88
      Programmer's Reference.</p>
 
89
  </description>
 
90
  <funcs>
 
91
    <func>
 
92
      <name>change_key(RegHandle, Key) -> ReturnValue</name>
 
93
      <fsummary>Move to a key in the registry</fsummary>
 
94
      <type>
 
95
        <v>RegHandle = term()</v>
 
96
        <v>Key = string()</v>
 
97
      </type>
 
98
      <desc>
 
99
        <p>Changes the current key to another key. Works like cd.
 
100
          The key can be specified as a relative path or as an
 
101
          absolute path, starting with \\.</p>
 
102
      </desc>
 
103
    </func>
 
104
    <func>
 
105
      <name>change_key_create(RegHandle, Key) -> ReturnValue</name>
 
106
      <fsummary>Move to a key, create it if it is not there</fsummary>
 
107
      <type>
 
108
        <v>RegHandle = term()</v>
 
109
        <v>Key = string()</v>
 
110
      </type>
 
111
      <desc>
 
112
        <p>Creates a key, or just changes to it, if it is already there. Works
 
113
          like a combination of <c>mkdir</c> and <c>cd</c>. Calls the Win32 API function
 
114
          <c>RegCreateKeyEx()</c>.</p>
 
115
        <p>The registry must have been opened in write-mode.</p>
 
116
      </desc>
 
117
    </func>
 
118
    <func>
 
119
      <name>close(RegHandle)-> ReturnValue</name>
 
120
      <fsummary>Close the registry.</fsummary>
 
121
      <type>
 
122
        <v>RegHandle = term()</v>
 
123
      </type>
 
124
      <desc>
 
125
        <p>Closes the registry. After that, the <c>RegHandle</c> cannot
 
126
          be used.</p>
 
127
      </desc>
 
128
    </func>
 
129
    <func>
 
130
      <name>current_key(RegHandle) -> ReturnValue</name>
 
131
      <fsummary>Return the path to the current key.</fsummary>
 
132
      <type>
 
133
        <v>RegHandle = term()</v>
 
134
        <v>ReturnValue = {ok, string()}</v>
 
135
      </type>
 
136
      <desc>
 
137
        <p>Returns the path to the current key. This is the equivalent of <c>pwd</c>.</p>
 
138
        <p>Note that the current key is stored in the driver, and might be
 
139
          invalid (e.g. if the key has been removed).</p>
 
140
      </desc>
 
141
    </func>
 
142
    <func>
 
143
      <name>delete_key(RegHandle) -> ReturnValue</name>
 
144
      <fsummary>Delete the current key</fsummary>
 
145
      <type>
 
146
        <v>RegHandle = term()</v>
 
147
        <v>ReturnValue = ok | {error, ErrorId}</v>
 
148
      </type>
 
149
      <desc>
 
150
        <p>Deletes the current key, if it is valid. Calls the Win32 API
 
151
          function <c>RegDeleteKey()</c>. Note that this call does not change the current key,
 
152
          (unlike <c>change_key_create/2</c>.) This means that after the call, the
 
153
          current key is invalid.</p>
 
154
      </desc>
 
155
    </func>
 
156
    <func>
 
157
      <name>delete_value(RegHandle, Name) -> ReturnValue</name>
 
158
      <fsummary>Delete the named value on the current key.</fsummary>
 
159
      <type>
 
160
        <v>RegHandle = term()</v>
 
161
        <v>ReturnValue = ok | {error, ErrorId}</v>
 
162
      </type>
 
163
      <desc>
 
164
        <p>Deletes a named value on the current key. The atom <c>default</c> is
 
165
          used for the the default value.</p>
 
166
        <p>The registry must have been opened in write-mode.</p>
 
167
      </desc>
 
168
    </func>
 
169
    <func>
 
170
      <name>expand(String) -> ExpandedString</name>
 
171
      <fsummary>Expand a string with environment variables</fsummary>
 
172
      <type>
 
173
        <v>String = string()</v>
 
174
        <v>ExpandedString = string()</v>
 
175
      </type>
 
176
      <desc>
 
177
        <p>Expands a string containing environment variables between percent
 
178
          characters. Anything between two % is taken for a environment
 
179
          variable, and is replaced by the value. Two consecutive % is replaced
 
180
          by one %.</p>
 
181
        <p>A variable name that is not in the environment, will result in an error.\011  </p>
 
182
      </desc>
 
183
    </func>
 
184
    <func>
 
185
      <name>format_error(ErrorId) -> ErrorString</name>
 
186
      <fsummary>Convert an POSIX errorcode to a string</fsummary>
 
187
      <type>
 
188
        <v>ErrorId = atom()</v>
 
189
        <v>ErrorString = string()</v>
 
190
      </type>
 
191
      <desc>
 
192
        <p>Convert an POSIX errorcode to a string (by calling <c>erl_posix_msg:message</c>).</p>
 
193
      </desc>
 
194
    </func>
 
195
    <func>
 
196
      <name>open(OpenModeList)-> ReturnValue</name>
 
197
      <fsummary>Open the registry for reading or writing</fsummary>
 
198
      <type>
 
199
        <v>OpenModeList = [OpenMode]</v>
 
200
        <v>OpenMode = read | write</v>
 
201
      </type>
 
202
      <desc>
 
203
        <p>Opens the registry for reading or writing. The current key will be the root
 
204
          (<c>HKEY_CLASSES_ROOT</c>). The <c>read</c> flag in the mode list can be omitted.</p>
 
205
        <p>Use <c>change_key/2</c> with an absolute path after <c>open</c>.</p>
 
206
      </desc>
 
207
    </func>
 
208
    <func>
 
209
      <name>set_value(RegHandle, Name, Value) -> ReturnValue</name>
 
210
      <fsummary>Set value at the current registry key with specified name.</fsummary>
 
211
      <type>
 
212
        <v>Name = string() | default</v>
 
213
        <v>Value = string() | integer() | binary()</v>
 
214
      </type>
 
215
      <desc>
 
216
        <p>Sets the named (or default) value to value. Calls the Win32
 
217
          API function <c>RegSetValueEx()</c>. The value can be of three types, and
 
218
          the corresponding registry type will be used. Currently the types supported
 
219
          are: <c>REG_DWORD</c> for integers, <c>REG_SZ</c> for strings and
 
220
          <c>REG_BINARY</c> for binaries. Other types cannot currently be added
 
221
          or changed.</p>
 
222
        <p>The registry must have been opened in write-mode.</p>
 
223
      </desc>
 
224
    </func>
 
225
    <func>
 
226
      <name>sub_keys(RegHandle) -> ReturnValue</name>
 
227
      <fsummary>Get subkeys to the current key.</fsummary>
 
228
      <type>
 
229
        <v>ReturnValue = {ok, SubKeys} | {error, ErrorId}</v>
 
230
        <v>SubKeys = [SubKey]</v>
 
231
        <v>SubKey = string()</v>
 
232
      </type>
 
233
      <desc>
 
234
        <p>Returns a list of subkeys to the current key. Calls the Win32
 
235
          API function <c>EnumRegKeysEx()</c>.</p>
 
236
        <p>Avoid calling this on the root keys, it can be slow.</p>
 
237
      </desc>
 
238
    </func>
 
239
    <func>
 
240
      <name>value(RegHandle, Name) -> ReturnValue</name>
 
241
      <fsummary>Get the named value on the current key.</fsummary>
 
242
      <type>
 
243
        <v>Name = string() | default</v>
 
244
        <v>ReturnValue = {ok, Value}</v>
 
245
        <v>Value = string() | integer() | binary()</v>
 
246
      </type>
 
247
      <desc>
 
248
        <p>Retrieves the named value (or default) on the current key.
 
249
          Registry values of type <c>REG_SZ</c>, are returned as strings. Type <c>REG_DWORD</c>
 
250
          values are returned as integers. All other types are returned as binaries.</p>
 
251
      </desc>
 
252
    </func>
 
253
    <func>
 
254
      <name>values(RegHandle) -> ReturnValue</name>
 
255
      <fsummary>Get all values on the current key.</fsummary>
 
256
      <type>
 
257
        <v>ReturnValue = {ok, ValuePairs}</v>
 
258
        <v>ValuePairs = [ValuePair]</v>
 
259
        <v>ValuePair = {Name, Value}</v>
 
260
        <v>Name = string | default</v>
 
261
        <v>Value = string() | integer() | binary()</v>
 
262
      </type>
 
263
      <desc>
 
264
        <p>Retrieves a list of all values on the current key. The values
 
265
          have types corresponding to the registry types, see <c>value</c>.
 
266
          Calls the Win32 API function <c>EnumRegValuesEx()</c>.</p>
 
267
      </desc>
 
268
    </func>
 
269
  </funcs>
 
270
 
 
271
  <section>
 
272
    <title>SEE ALSO</title>
 
273
    <p>Win32 Programmer's Reference (from Microsoft)</p>
 
274
    <p><c>erl_posix_msg</c></p>
 
275
    <p>The Windows 95 Registry (book from O'Reilly)</p>
 
276
  </section>
 
277
</erlref>
 
278