Using windll with complex data types
Robin Becker
robin at jessikat.fsnet.co.uk
Sat Nov 2 10:00:02 EST 2002
In article <8beb91f5.0211020556.30107507 at posting.google.com>, Ben C <benc1 at today.com.au> writes
....
I use the structob module to create structured things as for pointers
they are the address of something.
so for example a lasterror function looks like
def _lastErrorMessage(n=None):
msg = windll.cstring('',512)
kernel32.FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
0,
n is None and GetLastError() or n,
0,
msg.address(),
len(msg)-1,
0
)
return repr(msg)[1:-1]
we create the buffer and pass its address to the FormatMessage function.
If you really need pointer to pointer you need to create a buffer that holds the real address
eg
class pointer(structob.struct_object):
oracle = structob.Oracle (
'pointer',
'Nl',
('ref',)
)
then you can do
msg = windll.cstring('',512)
p=pointer()
p.ref = msg.address
so p points to msg and p.address() is a pointer to a pointer
>
>How does one pass reference to a pointer in a function?
>
>How does one retrieve data back from that pointer?
>
>How does one retrieve data back from aggregate data types such as
>structures and arrays?
>
>Thanks in advance
>
>Ben
--
Robin Becker
More information about the Python-list
mailing list