Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / handle-object.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="module--winreg.html" />
13<link rel="parent" href="module--winreg.html" />
14<link rel="next" href="module-winsound.html" />
15<meta name='aesop' content='information' />
16<title>22.2.1 Registry Handle Objects </title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="22.2 _winreg - Windows"
24 href="module--winreg.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="22.2 _winreg - Windows"
27 href="module--winreg.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="22.3 winsound "
30 href="module-winsound.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="module--winreg.html">22.2 _winreg - Windows</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module--winreg.html">22.2 _winreg - Windows</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-winsound.html">22.3 winsound </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION0024210000000000000000"></A><A NAME="handle-object"></A>
55<BR>
5622.2.1 Registry Handle Objects
57</H2>
58
59<P>
60This object wraps a Windows HKEY object, automatically closing it when
61 the object is destroyed. To guarantee cleanup, you can call either
62 the <tt class="method">Close()</tt> method on the object, or the
63 <tt class="function">CloseKey()</tt> function.
64
65<P>
66All registry functions in this module return one of these objects.
67
68<P>
69All registry functions in this module which accept a handle object
70 also accept an integer, however, use of the handle object is
71 encouraged.
72
73<P>
74Handle objects provide semantics for <tt class="method">__nonzero__()</tt> - thus
75<div class="verbatim"><pre>
76 if handle:
77 print "Yes"
78</pre></div>
79 will print <code>Yes</code> if the handle is currently valid (has not been
80 closed or detached).
81
82<P>
83The object also support comparison semantics, so handle
84 objects will compare true if they both reference the same
85 underlying Windows handle value.
86
87<P>
88Handle objects can be converted to an integer (eg, using the
89 builtin <tt class="function">int()</tt> function, in which case the underlying
90 Windows handle value is returned. You can also use the
91 <tt class="method">Detach()</tt> method to return the integer handle, and
92 also disconnect the Windows handle from the handle object.
93
94<P>
95<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
96 <td><nobr><b><tt id='l2h-5273' xml:id='l2h-5273' class="method">Close</tt></b>(</nobr></td>
97 <td><var></var>)</td></tr></table></dt>
98<dd>
99 Closes the underlying Windows handle.
100
101<P>
102If the handle is already closed, no error is raised.
103</dl>
104
105<P>
106<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
107 <td><nobr><b><tt id='l2h-5274' xml:id='l2h-5274' class="method">Detach</tt></b>(</nobr></td>
108 <td><var></var>)</td></tr></table></dt>
109<dd>
110 Detaches the Windows handle from the handle object.
111
112<P>
113The result is an integer (or long on 64 bit Windows) that holds
114 the value of the handle before it is detached. If the
115 handle is already detached or closed, this will return zero.
116
117<P>
118After calling this function, the handle is effectively invalidated,
119 but the handle is not closed. You would call this function when
120 you need the underlying Win32 handle to exist beyond the lifetime
121 of the handle object.
122</dl>
123
124<DIV CLASS="navigation">
125<div class='online-navigation'>
126<p></p><hr />
127<table align="center" width="100%" cellpadding="0" cellspacing="2">
128<tr>
129<td class='online-navigation'><a rel="prev" title="22.2 _winreg - Windows"
130 href="module--winreg.html"><img src='../icons/previous.png'
131 border='0' height='32' alt='Previous Page' width='32' /></A></td>
132<td class='online-navigation'><a rel="parent" title="22.2 _winreg - Windows"
133 href="module--winreg.html"><img src='../icons/up.png'
134 border='0' height='32' alt='Up One Level' width='32' /></A></td>
135<td class='online-navigation'><a rel="next" title="22.3 winsound "
136 href="module-winsound.html"><img src='../icons/next.png'
137 border='0' height='32' alt='Next Page' width='32' /></A></td>
138<td align="center" width="100%">Python Library Reference</td>
139<td class='online-navigation'><a rel="contents" title="Table of Contents"
140 href="contents.html"><img src='../icons/contents.png'
141 border='0' height='32' alt='Contents' width='32' /></A></td>
142<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
143 border='0' height='32' alt='Module Index' width='32' /></a></td>
144<td class='online-navigation'><a rel="index" title="Index"
145 href="genindex.html"><img src='../icons/index.png'
146 border='0' height='32' alt='Index' width='32' /></A></td>
147</tr></table>
148<div class='online-navigation'>
149<b class="navlabel">Previous:</b>
150<a class="sectref" rel="prev" href="module--winreg.html">22.2 _winreg - Windows</A>
151<b class="navlabel">Up:</b>
152<a class="sectref" rel="parent" href="module--winreg.html">22.2 _winreg - Windows</A>
153<b class="navlabel">Next:</b>
154<a class="sectref" rel="next" href="module-winsound.html">22.3 winsound </A>
155</div>
156</div>
157<hr />
158<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
159</DIV>
160<!--End of Navigation Panel-->
161<ADDRESS>
162See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
163</ADDRESS>
164</BODY>
165</HTML>