<p>看起来你做了一个<code>from ctypes import *</code>(糟糕的做法,因为人们只能猜测像<code>DWORD</code>这样的标识符到底是从哪里来的!-)但错过了<a href="http://docs.python.org/library/ctypes.html#ctypes.Structure" rel="nofollow noreferrer">ctypes.Structure's docs</a>中一段关键的短文:</p>
<blockquote>
<p>It is possible to define the <em>fields</em>
class variable after the class
statement that defines the Structure
subclass, <strong>this allows to create data
types that directly or indirectly
reference themselves</strong>:</p>
</blockquote>
<pre><code>class List(Structure):
pass
List._fields_ = [("pnext", POINTER(List)),
...
]
</code></pre>
<blockquote>
<p>The <em>fields</em> class variable must,
however, be defined before the type is
first used (an instance is created,
sizeof() is called on it, and so on).
Later assignments to the <em>fields</em>
class variable will raise an
AttributeError.</p>
</blockquote>
<p>因此,只需将这部分文档应用到您的代码中,您就需要将代码更改为:</p>
<pre><code>class EXCEPTION_RECORD(Structure):
pass
EXCEPTION_RECORD._fields_ = [
("ExceptionCode", DWORD),
("ExceptionFlags", DWORD),
("ExceptionRecord", POINTER(EXCEPTION_RECORD)),
("ExceptionAddress", LPVOID),
("NumberParameters", DWORD),
("ExceptionInformation", ULONG_PTR * EXCEPTION_MAXIMUM_PARAMETERS)]
</code></pre>