ctypes: using .value or .value() doesn't work for c_long
davea at davea.name
Wed Apr 15 23:03:40 CEST 2015
On 04/15/2015 03:48 PM, IronManMark20 wrote:
> I am using ctypes to call a few windll funcions. One of them returns a c_long object. I want to know what number the function returns.
> Problem is, when I try foo.value , it gives me this:
> AttributeError: LP_c_long object has no attribute value.
> Any idea of what could cause this?
I don't use Windows, so I can't try it, especially since you didn't
include any code <hint>. And apparently whatever function you're using
returns a pointer to a c_long, not a c_long.
I see Ian has given you an answer. But let me show you how you might
have come up with it on your own, for next time.
The fragment of the error you include says that the instance of the
class LP_c_long doesn't have an attribute called "value". But it
undoubtedly has other attributes, so you could look with dir
Presumably from there you'll see that you need the 'contents' attribute.
Then you print that out, and/or dir a dir() on it, and you see that
you now have a value attribute.
More information about the Python-list