I have a buffer like:
bufstr = ctypes.create_string_buffer("Test", 32)
How I obtain 开发者_开发百科the address of that buffer? i.e. the one displayed if I do:
print bufstr
like:
<ctypes.c_char_Array_32 object at 0x042ACAD0>
I know I can pass it with byref(), for example; but what if I just want to get that address (aside from slicing that string!)?
Thanks!
Use ctypes.addressof.
ctypes.addressof(bufstr)
I believe:
ctypes.addressof(bufstr)
should do it. Note that the address mentioned in toString is for the Python object, not the C memory.
精彩评论