开发者

Get the address of a ctypes object

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜