Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the value of a ctypes.c_ulong pointer?

Tags:

python

ctypes

For example:

pointer = ctypes.POINTER(ctypes.c_ulong)
b = pointer(ctypes.c_ulong(20))

What do I get the int value of b?

like image 628
Shane Avatar asked Jan 23 '15 05:01

Shane


1 Answers

You mean, dereference b to get that c_ulong(20)? That's b.contents. Or do you mean, see where in memory that pointer happens to point, as if it was an integer rather than a pointer? That's ctypes.cast(b, ctypes.c_void_p).value.

like image 169
Alex Martelli Avatar answered Oct 15 '22 15:10

Alex Martelli