File: win32reg.html

package info (click to toggle)
erlang-doc-html 1%3A8.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,028 kB
  • ctags: 7,419
  • sloc: perl: 1,841; ansic: 323; erlang: 155
file content (258 lines) | stat: -rw-r--r-- 10,447 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>win32reg</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>


<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>win32reg</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
win32reg</UL>
<H3>MODULE SUMMARY</H3>
<UL>
win32reg provides access to the registry on Windows</UL>
<H3>DESCRIPTION</H3>
<UL>
<P><CODE>win32reg</CODE> provides read and write access to the
registry on Windows. It is essentially a port driver wrapped around the
Win32 API calls for accessing the registry.
<P>The registry is a hierarchical database, used to store various system
and software information in Windows. It is available in Windows 95 and
Windows NT. It contains installation data, and is updated by installers
and system programs. The Erlang installer updates the registry by adding
data that Erlang needs.
<P>The registry contains keys and values. Keys are like the directories
in a file system, they form a hierarchy. Values are like files, they have
a name and a value, and also a type.
<P>Paths to keys are left to right, with sub-keys to the right and backslash
between keys. (Remember that backslashes must be doubled in Erlang strings.)
Case is preserved but not significant.
Example: <CODE>&#34;\\hkey_local_machine\\software\\Ericsson\\Erlang\\5.0&#34;</CODE> is the key
for the installation data for the latest Erlang release.
<P>There are six entry points in the Windows registry, top level keys. They can be
abbreviated in the <CODE>win32reg</CODE> module as:
<PRE>Abbrev.          Registry key
=======          ============      
hkcr             HKEY_CLASSES_ROOT
current_user     HKEY_CURRENT_USER
hkcu             HKEY_CURRENT_USER
local_machine    HKEY_LOCAL_MACHINE
hklm             HKEY_LOCAL_MACHINE
users            HKEY_USERS
hku              HKEY_USERS
current_config   HKEY_CURRENT_CONFIG
hkcc             HKEY_CURRENT_CONFIG
dyn_data         HKEY_DYN_DATA
hkdd             HKEY_DYN_DATA
    </PRE>
<P>The key above could be written as <CODE>&#34;\\hklm\\software\\ericsson\\erlang\\5.0&#34;</CODE>.
<P>The <CODE>win32reg</CODE> module uses a current key. It works much like the
current directory. From the current key, values can be fetched, sub-keys
can be listed, and so on.
<P>Under a key, any number of named values can be stored. They have name, and
types, and data.
<P>Currently, the <CODE>win32reg</CODE> module supports storing only the following
types: REG_DWORD, which is an
integer, REG_SZ which is a string and REG_BINARY which is a binary.
Other types can be read, and will be returned as binaries.
<P>There is also a &#34;default&#34; value, which has the empty string as name. It is read and
written with the atom <CODE>default</CODE> instead of the name.
<P>Some registry values are stored as strings with references to environment variables,
e.g. <CODE>&#34;%SystemRoot%Windows&#34;</CODE>. <CODE>SystemRoot</CODE> is an environment variable, and should be
replaced with its value. A function <CODE>expand/1</CODE> is provided, so that environment
variables surrounded in % can be expanded to their values.
<P>For additional information on the Windows registry consult the Win32
Programmer's Reference.
</UL>
<H3>EXPORTS</H3>
<P><A NAME="change_key%2"><STRONG><CODE>change_key(RegHandle, Key) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
<STRONG><CODE>Key = string()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Changes the current key to another key. Works like cd.
         The key can be specified as a relative path or as an
         absolute path, starting with \.
</UL>
<P><A NAME="change_key_create%2"><STRONG><CODE>change_key_create(RegHandle, Key) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
<STRONG><CODE>Key = string()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Creates a key, or just changes to it, if it is already there. Works
         like a combination of <CODE>mkdir</CODE> and <CODE>cd</CODE>. Calls the Win32 API function
         <CODE>RegCreateKeyEx()</CODE>.
        <P>The registry must have been opened in write-mode.
</UL>
<P><A NAME="close%1"><STRONG><CODE>close(RegHandle)-&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Closes the registry. After that, the <CODE>RegHandle</CODE> cannot
         be used.
</UL>
<P><A NAME="current_key%1"><STRONG><CODE>current_key(RegHandle) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
<STRONG><CODE>ReturnValue = {ok, string()}</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns the path to the current key. This is the equivalent of <CODE>pwd</CODE>.
        <P>Note that the current key is stored in the driver, and might be
         invalid (e.g. if the key has been removed).
</UL>
<P><A NAME="delete_key%1"><STRONG><CODE>delete_key(RegHandle) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
<STRONG><CODE>ReturnValue = ok | {error, ErrorId}</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes the current key, if it is valid. Calls the Win32 API
         function <CODE>RegDeleteKey()</CODE>. Note that this call does not change the current key,
         (unlike <CODE>change_key_create/2</CODE>.) This means that after the call, the
         current key is invalid.
</UL>
<P><A NAME="delete_value%2"><STRONG><CODE>delete_value(RegHandle, Name) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>RegHandle = term()</CODE></STRONG><BR>
<STRONG><CODE>ReturnValue = ok | {error, ErrorId}</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Deletes a named value on the current key. The atom <CODE>default</CODE> is
         used for the the default value.
        <P>The registry must have been opened in write-mode.
</UL>
<P><A NAME="expand%1"><STRONG><CODE>expand(String) -&#62; ExpandedString</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>String = string()</CODE></STRONG><BR>
<STRONG><CODE>ExpandedString = string()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Expands a string containing environment variables between percent
         characters. Anything between two % is taken for a environment
         variable, and is replaced by the value. Two consecutive % is replaced
         by one %.
        <P>A variable name that is not in the environment, will result in an error.      
</UL>
<P><A NAME="format_error%1"><STRONG><CODE>format_error(ErrorId) -&#62; ErrorString</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ErrorId = atom()</CODE></STRONG><BR>
<STRONG><CODE>ErrorString = string()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Convert an POSIX errorcode to a string (by calling <CODE>erl_posix_msg:message</CODE>).
</UL>
<P><A NAME="open%1"><STRONG><CODE>open(OpenModeList)-&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>OpenModeList = [OpenMode]</CODE></STRONG><BR>
<STRONG><CODE>OpenMode = read | write</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Opens the registry for reading or writing. The current key will be the root
         (<CODE>HKEY_CLASSES_ROOT</CODE>). The <CODE>read</CODE> flag in the mode list can be omitted.
        <P>Use <CODE>change_key/2</CODE> with an absolute path after <CODE>open</CODE>.
</UL>
<P><A NAME="set_value%3"><STRONG><CODE>set_value(RegHandle, Name, Value) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Name = string() | default</CODE></STRONG><BR>
<STRONG><CODE>Value = string() | integer() | binary()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Sets the named (or default) value to value. Calls the Win32
         API function <CODE>RegSetValueEx()</CODE>. The value can be of three types, and
         the corresponding registry type will be used. Currently the types supported
         are: <CODE>REG_DWORD</CODE> for integers, <CODE>REG_SZ</CODE> for strings and
         <CODE>REG_BINARY</CODE> for binaries. Other types cannot currently be added
         or changed.
        <P>The registry must have been opened in write-mode.
</UL>
<P><A NAME="sub_keys%1"><STRONG><CODE>sub_keys(RegHandle) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ReturnValue = {ok, SubKeys} | {error, ErrorId}</CODE></STRONG><BR>
<STRONG><CODE>SubKeys = [SubKey]</CODE></STRONG><BR>
<STRONG><CODE>SubKey = string()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Returns a list of subkeys to the current key. Calls the Win32
         API function <CODE>EnumRegKeysEx()</CODE>.
        <P>Avoid calling this on the root keys, it can be slow.
</UL>
<P><A NAME="value%2"><STRONG><CODE>value(RegHandle, Name) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Name = string() | default</CODE></STRONG><BR>
<STRONG><CODE>ReturnValue = {ok, Value}</CODE></STRONG><BR>
<STRONG><CODE>Value = string() | integer() | binary()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Retrieves the named value (or default) on the current key.
         Registry values of type <CODE>REG_SZ</CODE>, are returned as strings. Type <CODE>REG_DWORD</CODE>
         values are returned as integers. All other types are returned as binaries.
</UL>
<P><A NAME="values%1"><STRONG><CODE>values(RegHandle) -&#62; ReturnValue</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ReturnValue = {ok, ValuePairs}</CODE></STRONG><BR>
<STRONG><CODE>ValuePairs = [ValuePair]</CODE></STRONG><BR>
<STRONG><CODE>ValuePair = {Name, Value}</CODE></STRONG><BR>
<STRONG><CODE>Name = string | default</CODE></STRONG><BR>
<STRONG><CODE>Value = string() | integer() | binary()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Retrieves a list of all values on the current key. The values
         have types corresponding to the registry types, see <CODE>value</CODE>.
         Calls the Win32 API function <CODE>EnumRegValuesEx()</CODE>.
</UL>
<H3>SEE ALSO</H3>
<UL>
<P>Win32 Programmer's Reference (from Microsoft)
<P><CODE>erl_posix_msg</CODE>
<P>The Windows 95 Registry (book from O'Reilly)
</UL>
<H3>AUTHORS</H3>
<UL>
Bjorn Gustavsson - support@erlang.ericsson.se<BR>
Jakob Cederlund - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright &copy; 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>